Many of the foods we eat have defence mechanisms that work to try to prevent us from eating them. However, that defence mechanism has been what makes the food have a tangy, spicy, or bitter taste. For instance, the sour and tangy taste of Pineapple comes from the juice of the fruit working to literally digest us, and prevent us from eating it. That has not worked as of yet.
Cinnamon has a similar thing going for it as well. Trying to consume a spoonful of cinnamon causes you to have a violent coughing fit. This is because the powdered spice is working to literally burn your mouth, and prevent you from eating it.
The same can be said for Chilis, although their defence mechanism has a secondary function for the plant itself. These peppers are spicy due to a chemical they create known as capsaicin. Since they grow in areas that are wet and hot, like South America, or your bathroom after a hot shower, it is easy for plants to become infected with bacteria and fungi. This chemical helps to irritate potential invaders, thus protecting the plant from being consumed by fungus.
It’s odd how despite this hot taste usually being a sign that we should not eat something, we humans kept eating it until we adapted. So the next time that you bit into a delicious taco, or eat a spicy curry, realize that the spicy feeling that you have in your mouth is the plant trying to stop you from eating it. Nature is mental sometimes.