It is dangerous to be a caterpillar. Not only are they and other maggots, grubs and insect larvae subject to predation by birds, small mammals and reptiles but they face an even creepier danger from other insects. Wasps. in particular, have developed a method of ensuring that their own larvae have both a good food supply and protection from predators. The stingers that wasps carry have other purpose besides as a potent weapon against attackers. It is also hollow, like a needle and is an ovipositor, an appendage designed for putting eggs inside things. Living things. Caterpillars and other fat, juicy insect larvae.
Female wasps mate and then fly around looking for suitable hosts. Sometimes it is a simple matter of finding a nice juicy caterpillar on a leaf. The wasp inserts her hypodermic needle into the body of the caterpillar and deposits one or more eggs. The eggs develop into larvae called parasitoids. This term is related to the word parasite because it lives a parasitic lifestyle. A parasitoid is a particular kind of parasite: the juvenile larve of a number of wasp species (plus some rove beetles) who are inserted by their mothers into a larval host to grow and feed on. The host is often 'directed' somehow by the parasitoids to go into a feeding frenzy and so provide even more food for the rather ghastly organism that infests it and is killing it.
Why do they do it? Because the strategy has survival value for the vulnerable wasp larvae. A grub is a grub to an insectivorous bird and these larvae do not have stinging ovipositors to protect themselves. So the mother finds a host in which her larvae have an ample food supply and extra protection from predators. Sick caterpillars probably suffer from a higher predation rate than healthy caterpillars, so some will be eaten but the odds for the wasp larvae still beat being left out unprotected and unfed in the open.
Whole families of wasps and numerous species have evolved as the rest of the insect world plus other terrestrial invertebrates evolved and adaptively radiated into every possible habitat and niche. Wasps can be very host-specific. There are species that specialise in spiders. These big, powerful wasps can poison a spider with their stings and then drag the stunned victim to a specially prepared hole where it is left with a belly-full of parasitoids to end its existence in an excellent nursery.
There are wasps with long thin ovipositors who specialise in beetle larvae hidden deep under the bark and in the wood of numerous tree species. The wasp will dance on the tree with her legs, drumming and sensing changes in the echos when a soft bodied grub is passed over. In goes her ovipositor, reaching through the wood layers until it finds the helpless beetle grub. There are many tiny wasps that look for ant and bee larvae in hives or termites under the ground. There are even tinier wasps that look for the larvae of the smallest insects such as Thrips which infest flowers and fruits in many agricultural industries.
Wasps are already a potent biological weapon in the war against agricultural pests. They already keep down the numbers of many non-pest species in wild habitats. Without them, trees and shrubs could potentially be stripped of their vegetation and die. In orchards and gardens these wasps can assist in keeping down the numbers of pests to acceptable levels without poisoning the environment with as many, or hopefully any, pesticides. Their life style is cruel and rather horrific to think about. Imagine a horror movie where a giant wasp lays eggs in the bodies of terrified humans and then they get eaten out and die horribly. That is the fate of many a caterpillar and I for one am glad there are no giant human-attacking wasps.
Why not? Well thankfully, the Achilles Heel of Arthropods is their size. The largest insects that ever lived were the dragonflies of the ancient Carboniferous Fern forests. They got up to 2 meters across - big, but no match for an elephant or blue whale. The difference: endoskeleton versus exoskeleton. We can hang much bigger bodies on our internal clothes-rack than insects can make inside a shell. Thank goodness. We are having enough trouble staying ahead of them as it is and we have enough problems without having to avoid giant wasps that could parasitise us with their larvae!