When a child grows up, he changes his clothes into a bigger one. Likewise, an insect turns into a new body, throwing away its old self that no longer fits itself in due time. This is called molting.
The process by which insects are newly born through molting is never smooth. While taking off their exoskeleton, they sometimes get wounded or finish their life, failing to get out of it due to lack of strength. Right after they molted, their skin is soft and they act unnaturally that they are vulnerable to attack by other insects. Despite a number of dangers and pains that follow, insects molt several times in their lives because there is no growth without molting.
The skin and exoskeleton that reptiles and insects take off as they grow resemble the shape of their body. Before they molted, as the skin and exoskeleton were also a part of their body, it may be so difficult to remove them. But the insects endure the difficult process probably because they know the reason by instinct: When they put off their outer body, their better and new life is waiting for them.