According to Business Insider, “First, it releases enzymes called caspases. These rip apart and dissolve cells in its muscles, digestive system, and other organs. But the enzymes don’t quite liquefy all of the caterpillar. They leave key structures intact, like breathing tubes. At the same time, specialized cells called imaginal discs start waking up. Once the transformation begins, those hormone levels take a nosedive, giving these discs the opportunity to do what they do best: build a butterfly. You see, each disc contains the genetic recipe to form a different adult body part, starting from the inside out.

Research suggests that butterflies and moths can remember their caterpillar days.”

Source: https://www.buzzfeed.com/morganmurrell/obscure-animal-facts