…the chili sensation isn’t just warm: It hurts! It is a form of pain and irritation. There’s no obvious biological reason why humans should tolerate it, let alone seek it out and enjoy it. For centuries, humans have eagerly consumed capsaicin—the molecule that generates the heat sensation—even though nature seems to have created it to repel us.
Like our affection for a hint of bitterness in cuisine, our love of spicy heat is the result of conditioning. The chili sensation mimics that of physical heat, which has been a constant element of flavor since the invention of the cooking fire: We have evolved to like hot food. The chili sensation also resembles that of cold, which is unpleasant to the skin but pleasurable in drinks and ice cream, probably because we have developed an association between cooling off and the slaking of thirst. But there’s more to it than that.
There is the argument that eating spicy food is beneficial in hotter climates (closer you get to the equator) because it provokes sweating, cooling you off. Which makes sense that the rats in the studies would not take to consuming spicy food – rats, like dogs, do not sweat.
Spices, not just spicy ones, had been used for preservation (including bacteria killing) before refrigeration became possible.