Caffeine can kill or inhibit the growth of the larvae of several species of insects  One recent experiment showed that tobacco hornworm larvae die when they ingest a preparation that consists, in part, of finely powdered tea leaves, which contain caffeine
This result is evidence for the hypothesis that the presence of non-negligible quantities of caffeine in various parts of many diverse species of plants is not accidental but evolved as a defense for those plants
caffeine-producing plants or their ancestors have at some time been subject to being fed upon by creatures sensitive to caffeine