Caterpillars take the medicine they need. Scientists have discovered that when caterpillars get sick, they go looking for a special plant that can help them and they eat the leaves. This helps the caterpillars to recover.
Source: Choi, Charles Q. (2009, March 13). “A Toxin a Day Keeps the Maggots Away.” ScienceNow Daily News.