Many different types of tree-leaf feeding caterpillars do this; there r at least two reasons. As forex says - if a predator, like a spider, approaches, some species drop on a line of silk to avoid getting eaten. At other times & with other types of caterpillars, they dangle on a line because they're ready to turn into moths. They need a safer place to make a cocoon & pupate so they dangle until it feels right & then, hopefully, the wind will blow them into a lower, warmer & safer place to spend the winter in their cocoon. In the spring, they turn into moths & lay eggs on the leaves of the same type of tree that they grew up on. They’re usually small moths that nobody ever sees - unless they look. They spin silk from modified salivary glands which secrete a strong, elastic thread through spinnerets right next to their mouths; it’s similar to spider silk but their own recipe.