When food goes bad and starts to become pungent, it is most often due to the growth of spoilage microbes such as bacteria, yeasts and mold. Odors can come from two sources: chemicals that are released from the food as the microbes decompose it, or chemicals produced directly by the microbes themselves.
Spoilage odors come in many flavors, depending on the type of spoilage microbe and the food being spoiled. Pseudomonas fragi, a bacterium that can commonly spoil dairy products, has an almost pleasant strawberry odor. Some yeasts produce sulfur compounds that resemble human flatulence. As molds decompose foods, they give off musty, earthy aromas similar to an old basement.
Why do these microbes go to all the trouble to produce such a frightening bouquet of rotten odors? In some cases, microbial odors are probably just byproducts of other essential processes that the microbes need to engage in for survival. In other cases, those rotten smells could be byproducts of microbial warfare. Aromatic compounds related to food spoilage have been shown to play important roles in the interactions between microbial species.
Some scientists have suggested—although it's quite difficult to prove—that microbes have evolved to produce these odors as a way to compete with humans and other large animals. By making food unappealing to us, the microbes are stealing our resources for their own survival.
While we tend to think of rotting food as a bad thing, humans have figured out how to intentionally rot foods to give them unique flavors. In fermented foods, desirable microbes are encouraged to grow on raw materials like cabbage, milk or meat to create products such as sauerkraut, cheese or salami. Some of these fermentation microbes—which we study in my lab—are quite similar to or even the same as microbes that can cause spoilage.
It's extremely important to note that the smell test is not a sure bet when evaluating whether food is safe to eat. Many of the microbes that can cause food-borne illness do not produce detectable odors when they grow in food. Just because a suspicious food item doesn't smell bad doesn't mean it's safe for consumption. When in doubt, throw it out.
Explore further: Are tiny microbes outwitting us to steal our food?