This is called metamorphosis. Some insects, such as grasshoppers, mayflies, roaches, and cicadas, change gradually. They start out as eggs, then become nymphs that molt several times, and finally change into adults. Entomologists call this incomplete metamorhosis. This is called complete metamorphosis.
Insects protect their pupae in a variety of ways.
Some insects spare no expense or trouble to make cocoons. The silkworm spins a cocoon of silk for pupation. Centuries ago, it was discovered that the silken thread used by silkworm larvae to construct pupation chambers could be unwound and used for human purposes. Compared with people, insects are very strong. Many insects can carry 50 times their own weight.