Fruits, and by extension peppers, evolved to be eaten. Peppers are the fruit of the pepper plant, and generally speaking, fruits act as an enticement for animals to eat them and thus distribute their seeds.
It's just that hot peppers specifically appear to have evolved a strategy to dissuade mammals from eating them, since the chemical that causes them to be hot primarily affects mammals, but not birds. It's actually not an uncommon strategy, many fruits are distasteful or even poisonous to certain animals, but are perfectly edible to other animals in a way that suggests it is specifically beneficial to be eaten by some but not by others.
Fun fact: some fruit evolved to be eaten by mega fauna, giant animals, that no longer exist because uh we ate them. One of those is Avocado. A pit that is way too big to be eaten by fauna of current day size.
I've heard the argument that the evolution of our ability to enjoy such things benefits both that pungent plant as well as us. By eating such things, we propagate them better. But the kind of insects and animals that would otherwise eat them wouldn't assist propagation. So the plants evolved to both repel the disadvantageous eaters and attract the advantageous eater by the same method.
I kinda think that falls apart with horseradish though. Afaik, humans don't spread anything directly with that. We can cultivate it, which helps the plant, but that's not the same action as digging up garlic, eating some, and spreading the cloves, or the seeds from peppers. That puts a hole in this specific set of plants with that idea.
Peppers are that way because birds don't taste the hotness and they spread seeds further than other animals.
I guess humans spread seeds even further as you can get them shipped from another continent really easily. Although birds also fly those distances, they poop more frequently.
Growing my first horseradish plant this year. Do we not spread it around by breaking off chunks of root and sharing them around? Same as garlic, we're taking pieces of root to grow more?
The Botany of Desire by Michael Pollan is about this. It follows four plants- Tulips, Apples, Cannabis and Potatoes through the changes that they have been through as they trick us into domesticating them/we adjust their genetics to suit us. Spoiler: the chapter on Potatoes is largely about RoundUp Ready GMOs and how we are ruining the world so that McDonald's can have long, beautiful french fries from one specific, blight prone variety and is really depressing (but still interesting!).