Snakes shed their skin for two main reasons. The first is to facilitate continued growth. This occurs as snakeskin does not grow in partnership with the snake itself, unlike in humans, where millions of skin cells are shed each year continuously on a microscopic, unseen level. On the contrary, snakes cannot shed skin in this microscopic way, necessitating them to literally outgrow the outer layer of skin whole on a frequent basis. The frequency that snakes shed their skin is largely dependent on the stage of life cycle they are in, with sheddings incredibly frequent during infancy and teenage years (bi-monthly in some species), but slowing to a couple of times per year as adults.
The second reason why snakes shed their skin is to preserve their health. Poor living conditions (lack of humidity, lack of vegetation, excess heat, and so on) as well as an inadequate food source can lead to skin damage and parasites. If left unchecked for a long period of time in the wild, this would be highly detrimental to the snake’s well being. By shedding its skin, the snake can mitigate these potentially damaging conditions and start a new.
Interestingly, however, the shedding process brings with it complications. For the week or two preceding the shedding, the snake’s vision is impaired due to the loosening of the skin’s outer layer, and the week or two after the event, the new outer layer is soft and vulnerable to attack from predators. For this reason, snakes tend to be overly protective around sheddings, and largely inactive if possible. The snake initializes each shedding by rubbing itself against a sharp object such as rock, to pierce the outer layer of skin.