Insects grow by molting or shedding of skin (integument). At the end of each molt, the insect is a little larger and different than before. Molting continues until the insect grows into adult. Adult insects do not molt or grow.
Molting, growth, and pupation are controlled by hormones. These are special chemical substances secreted by certain brain cells and glands. Hormones are released into circulation to discharge their duty.
In the larva, there are two tiny glands called Corpora allata, behind the brain. These secrete Juvenile Hormone or JH, for short.
The JH exerts its influence on another set of glands, the Prothoracic glands, which secrete a hormone called, Ecdysone.
Both JH and Ecdysone control, molting, growth and pupation, eventually leading to the development of adult. This is how it happens.
Ecdysone is the molting hormone, which promotes molting. As long as enough JH is secreted, Ecdysone will continue to promote molting in the larva. When the amount of JH reduces, Ecdysone will stop the molting process and start promoting the formation of pupa. Once the pupa is formed, the JH secretion stops. The pupa now begins to develop into adult.
Obviously, it is the interplay of these hormones that is so important in the development of insects.
Of the two hormones, the JH appears to prevent the development of adult characters, when the larva is busy eating and growing. This is important for the larva to store enough food reserves in its body for the next stages in development. The JH allows series of molting to happen, controlled by the second hormone, Ecdysone. At one stage, secretion of JH stops, pupation and development into adult happens.
It is a sort of a programme of events happening one after another. The appearance of larva and cocoon is deceptive but there is a drama taking place inside their body. The hormones conduct the drama!