Shivering is the body's defensive response to a drop in body temperature.
When the temperature drops, biochemical reactions slow down, and the lower the temperature, the more likely they are to stop altogether.
The skeletal muscles of any warm-blooded animal, contracting, produce a certain amount of work, which results in the release of heat. Shivering allows us to correlate the expenditure of energy and the heat received.