The correct answer is: Individuals that produce chemical compounds are better protected from herbivores and are able to produce more young than individuals that do not produce the compounds.
Natural selection acts on variations-differences in phenotype that exist among individuals. If a certain trait contribute more to survival and reproduction (individuals with that variant survive more than individuals with other variant), natural selection will favor that trait. In this case, production of chemical compounds is favored over non-producing trait.