Question
Quite a few plant species can be used for medicinal purposes wiki. As an example, Filipendula ulmaria is rich in acetylsalicylic acid (aspirin).
An allele that produces a substance which is beneficial for a predator should not get fixed in the population! Why are there so many drug-like plants?
Thoughts
Here are some (intuitive, unclear or far-fetched, non-exhaustive and non-exclusive) hypotheses I can think of:
Because plants want their seeds to get ingested in order to propagate
Is it because there are so many substances that affect our homeostasy that many plants are toxic and many are healthy just by chance. Containing healthy substances are not adaptations but by-product of evolution.
The substances that are beneficial for us actually evolved to repulse predators. These substances are toxic at high dosage and therefore are efficient against predators that are small or eat a lot of plants (herbivorous). These substances at low dosage might actually have a benefical effect. For example a substance that make blood thicker is very toxic except if you eat just a bit of it while bleeding.
We (primate or whatever taxon you want to consider) evolved in order to get advantage of the surrounding envirronment. Sbstances that were neutral became beneficial. The advantage of being sensitive to various products cause that, by chosing our food source, we can heal. Therefore, by evolving sentivity to various substances, our behaviour can act as a reinforcement to immunity (and other anti-illness system). If this is true, we might expect that the frequency of presence of a plant species affect the probability that out homeostasy get affected when eating it.
Lineage selection. Lineages that produce substances that are active in predators body in a way or another are undergoing many various selection forces because of these substances. Therefore they get a higher speciation rate than other lineages.
Keeping some non-herbivorous species in large population size (by helping them) is the best way to keep herbivorous species in small population (because of territory competition, predators relationships, etc... )