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.