When your body gets cold enough, muscles begin contracting rapidly and involuntarily.
That is shivering.
The movement is not very useful for getting work done.
It is useful for making heat.
Muscles produce heat when they contract
Muscle cells use energy every time they contract.
Not all of that energy becomes movement.
A substantial amount becomes heat.
During shivering, many muscles contract repeatedly without producing coordinated motion.
The point is heat production.
Your brain watches body temperature
The hypothalamus helps regulate body temperature.
It receives information from temperature sensors in the skin and deeper parts of the body.
If body temperature starts dropping, several responses can begin.
Blood vessels near the skin may narrow.
You may change behavior.
And if necessary, shivering starts.
Why do your teeth chatter?
The jaw muscles can join the same involuntary activity.
Rapid contractions move the jaw enough for teeth to tap together.
The sound is a side effect of the heating response.
Is shivering the same as getting goosebumps?
No.
Goosebumps come from tiny muscles pulling on hair follicles.
Shivering uses much larger skeletal muscles.
Both are old cold-response systems, but shivering produces far more useful heat in humans.
Why can a fever make you shiver?
During a fever, the brain’s temperature set point can temporarily rise.
Now your current body temperature feels too low relative to the new target.
That can trigger shivering even though your temperature is already elevated.
This is why a fever can make you feel freezing cold.
When does shivering stop being enough?
In severe cold, the body can lose heat faster than shivering can replace it.
That can lead to hypothermia.
So shivering is useful, but it is not unlimited protection.
It is your muscles doing emergency heat production without waiting for permission.
And that’s the short explanation.
Related explanations: Why do we get goosebumps?, Why can a fever make you feel cold?, and Why do we sweat?