Most of the interesting-tasting or psychoactive chemicals that plants make are there to ward off being eaten or infected. Caffeine and mint oil are among the plant insecticides, all sorts of other things are toxins to vertebrates. By virtue of being megafauna we can tolerate amounts of toxic stuff that will kill smaller organisms by mixing them with other foods, and our particular biochemistry happens to be particularly strong against some (and weak against others, just try to eat hemlock). Stuff we can tolerate but still has effects on us (caffeine, capsaicin) can be interestingly psychoactive, stuff that doesn’t hurt us can be interesting to taste (mint, cinnamon, garlic), and there’s interesting correlations between spice use and parasite load in food (that could be confounded six ways to mars)...
Most of the interesting-tasting or psychoactive chemicals that plants make are there to ward off being eaten or infected. Caffeine and mint oil are among the plant insecticides, all sorts of other things are toxins to vertebrates. By virtue of being megafauna we can tolerate amounts of toxic stuff that will kill smaller organisms by mixing them with other foods, and our particular biochemistry happens to be particularly strong against some (and weak against others, just try to eat hemlock). Stuff we can tolerate but still has effects on us (caffeine, capsaicin) can be interestingly psychoactive, stuff that doesn’t hurt us can be interesting to taste (mint, cinnamon, garlic), and there’s interesting correlations between spice use and parasite load in food (that could be confounded six ways to mars)...
Nicotine, too, is an insecticide.