content: It's likely aposematism, or warning coloration. If a predator tries to eat one of those caterpillars, it'll be turned off because the caterpillar is spiky or poisonous. From then on, the predator remembers that there's no use in pursuing that type of prey. Non-dangerous prey has also evolved warning coloration to mimic truly dangerous species, and it does help ward off predators. Hoverflies are good examples of this.