As I write this, my mouth is currently a bit aflame, owing to a side of beans which had been spiced with a hot pepper (serrano, to be precise). Across the world (and across YouTube), people partake in the consumption of spicy - and spiced - foods. On the surface, this behavior seems rather strange owing to the pain and other unpleasant feelings induced by such foods. To get a real quick picture of how unpleasant these food additives can be, you could always try to eat an whole raw onion or spicy pepper, though just imagining the experience is likely enough (just in case it isn't, YouTube will again be helpful). While this taste for spices might be taken for granted - it just seems normal that some people like different amounts of spicy foods - it warrants a deeper analysis to understand this ostensibly strange taste. Why do people love/hate the experience of eating spicy foods?
Food preferences do not just exist in a vacuum; the cognitive mechanisms which generate such preferences need to have evolved owing to some adaptive benefits inherent in seeking out or avoiding certain potential food sources. Some of these preferences are easier to understand than others: for example, our taste for certain foods we perceive as sweet - sugars - likely owes its existence to the high caloric density that such foods historically provided us (which used to be quite valuable when they were relatively rare. As they exist in much higher concentrations in the first world - largely due to our preferences leading us to cultivate and refine them - these benefits can now dip over into costs associated with overconsumption and obesity). By contrast, our aversion to foods which appear spoiled or rotten helps us avoid potentially harmful pathogens which might reside in them; pathogens which we would rather not purposefully introduce into our bodies. Similar arguments can be made for avoiding foods which contain toxic compounds and taste correspondingly unpleasant. When such toxins are introduced into our bodies, the typical physiological response is nausea and vomiting; behaviors which help remove the offending material as best we can.
So where do spicy foods fall with respect to what costs they avoid or benefits they provide? As many such foods do indeed taste unpleasant, it is unlikely that they are providing us with direct nutritional benefits the way that more pleasant-tasting foods do. That is to say we don't like spicy foods because they are rich sources of calories or vital nutrients. Indeed, the spiciness that is associated with such foods represents chemical weaponry evolved on the part of the plants. As it turns out, these plants have their own set of adaptive best interests which often include not being eaten at certain times or by certain species. Accordingly, they develop certain chemical weapons that dissuade would be predators from chowing down (this is the reason that the selective breeding of plants for natural insect resistance ends up making them more toxic for humans to eat as well. Just because pesticides aren't being used, that doesn't mean you're avoiding toxic compounds). Provided this analysis is correct, then, the natural question arises of why people would have a taste for plants that possess certain types and amounts of chemical weaponry designed to prevent their being eaten. On a hedonic level, growing crops of jalapenos seems as peculiar as growing a crop of edible razor blades.
The most likely answer to this mystery comes in the form of understanding what these chemical weapons do not to humans, but rather what they do to the other pathogens that tend to accompany our other foods. If these chemical weapons are damaging to our bodies - as evidenced by the painful or unpleasant tastes that accompany them - it stands to reason they are also damaging to some pathogens which might reside in our food as well. Provided our bodies are better able to withstand certain doses of these harmful chemicals, relative to the microbes in our food, then eating spicy foods could represent a trade-off between the killing food-borne pathogens against the risk of poisoning ourselves. Provided the harm done to our bodies by the chemicals is less than the expected damage done by the pathogens, a certain perverse taste for spicy foods could evolve.
A healthy degree of empirical evidence is consistent with such an adaptive hypothesis from the world over. One of the most extensive data sets focuses on recipes found in 93 traditional cookbooks from 36 different countries across the world (Sherman & Billing, 1999). The recipes in these cookbooks were examined for which of 43 spices were added to meat dishes. Of the approximately 4,500 different meat dishes present in these books, the average number of spices called for by the recipes was 4, with 93% of recipes calling for at least one. Importantly, the distribution of these spices was anything but random. Recipes coming from warmer climates tended to call for a much greater use of spices. The probable reason this finding emerged relates to the fact that, in warmer climates, food - especially meats - which would have been unrefrigerated for most of human history (alien as that idea sounds currently) will tend to spoil quicker, relative to cooler climates. Accordingly, as the degree and speed of spoilage tended to increase in warmer climates, a greater use of anti-microbial spices can be introduced to dishes to help combat food-borne illness. To use one of their examples, the typical Norwegian recipe called for 1.6 spices per dish and the recipes only mentioned 10 different spices; in Hungary, the average number of spices per dish was 3, and up to 21 different spices were referenced. It is not too far-fetched to go one step further and suggest that people indigenous to such regions might also have evolved slightly different tolerances for spices in their meals.
Even more interestingly, those spices with the strongest anti-microbial effects (such as garlic and onions) also tended to be the ones used more often in warmer climates, relative to cooler ones. Among the spices which had weaker effects, the correlation between temperature and spice use ceased to exist. Nevertheless, the most inhibitory spices were also the ones that people tended to use most regularly across the globe. Further, the authors also discuss the trade-off between balancing the fighting of pathogens against the possible toxicity of such spices when consumed in large quantities. A very interesting point bearing on that matter concerns the dietary preferences of pregnant women. While an adult female's body might be able to tolerate the toxicity inherent in such compounds fairly well, the developing fetus might be poorly equipped for the task. Accordingly, women in their first trimester tend to show a shift in food preferences towards avoiding a variety of spices, just as they also tend to avoid meat dishes. This shift in taste preferences could well reflect the new variable of the fetus being introduced to the usual cost/benefit analysis of adding spices to foods.
An interesting question related to this analysis was also posed by the Sherman & Billing (1999): do carnivorous animals ingest similar kinds of spices? After all, if these chemical compounds are effective at fighting against food-borne pathogens, carnivores - especially scavengers - might have an interest in using such dietary tricks as well (provided they did not stumble upon a different adaptive solution). While animals do not appear to spice their foods the way humans do, the authors do note that vegetation makes up a small portion of many carnivore's diets. Having owned cats my whole life, I confess I have always found their behavior of eating the grass outside to be quiet a bit odd: not only does the grass not seem to be a major part of a cat's diet, but it often seems to make them vomit with some regularity. While they present no data bearing on this point, Sherman & Billing (1999) do float the possibility that a supplement of vegetation to their diet might be a variant of that same kind of spicing behavior: carnivores eat vegetation not necessarily for its nutritional value, but rather because of possible anti-microbial benefits. It's certainly an idea worth examining further, though I know of no research at present to have tackled the matter.
I find this kind of analysis fascinating, frankly, and would like to take this moment to mention that these fascinating ideas would be quite unlikely to have stumbled upon without the use of evolutionary theory as a guide. The typical explanation you might get when asking people about why we spice food would typically sound like "because we like the taste the spice adds"; a response as uninformative as it is incorrect, which is to say "mostly" (and if you don't believe that last part, go ahead an enjoy your mouthfuls of raw onion and garlic). The proximate taste explanation would fail to predict the regional differences in spice use, the aversion to eating large quantities of them (though this is a comparative "large", as a slice of Jalapeno can be more than some people can handle), and the maternal data concerning aversions to spices during critical fetal developmental windows. Taste preferences - like any psychological preferences - are things which require deeper explanations. There's a big difference between knowing that people tend to add spices to food and knowing why people tend to do so. I would think that findings like these would help psychology researchers understand the importance of adaptive thinking. At the very least, I hope they serve as food for thought.
References: Sherman, P. & Billing, J. (1999). Darwinian gastronomy: Why we use spices. Bioscience, 49, 453–463.