mouse quoted Eight Flavors by Sarah Lohman
When black pepper was first being consumed in large quantities in the early nineteenth century, it was considered hot, due to its piperine content. Chili peppers contain a structurally similar chemical called capsaicin -- both are considered chemical irritants.
Capsaicin bons to nerve cells in our mouth and nose; specifically to receptors called TRPV1. This receptor is designed to warn us about dangerous sensations such as acid, abrasions, and heat. Capsaicin triggers a "hot" response, which is why we feel warm when we eat it: our body interprets capsaicin as thermally warm, hence the use of the word heat when we refer to this particular type of spice.
— Eight Flavors by Sarah Lohman (Page 57)