A caterpillars one and only job is to eat as much as it can.
Picture from Amazing Butterflies
During the larval stage, the caterpillar must consume enough to sustain itself into adulthood. Without proper nutrition, it may not have the energy to complete its metamorphosis, or may be unable to develop eggs as an adult. Caterpillars can eat an enormous amount during a life cycle stage that typically lasts several weeks. Some consume 27,000 times their body weight during this life phase.