Teeth chattering is just a symptom of shivering. Endotherms (that’s you, me, other mammals, birds, and some insects) produce heat within the body. They use thermoregulation to keep their bodies at a constant temperature. You can thermoregulate physiologically and behaviourally. Shivering is a physiological response to cold, it’s coming from inside. Putting on a jacket because you’re cold is a behavioural response.
Let’s say you’re cold and you won’t put on a jacket, or do a lap around the block to keep warm. Your brain tells your body what it needs to do. The brain — the hypothalamus, to be specific — monitors your temperature. Get too cold and and the hypothalamus sends nerve impulses to the skin and you get goose bumps. The goose bumps are caused by teeny muscles attached to the base of your hair follicles. Since humans lack a tonne of body hair, the goose bumps do little to make us warmer. But for furry animals those little muscles create better insulation. The muscles raise the hairs and the hairs trap air next to the skin. Because air is an insulator, this air next to the skin acts like a blanket to keep an animal warm.
Let’s go back to you. You’re cold and you’re just not furry enough to use air as a blanket. Your muscles get a signal to start contracting — that’s the shivering and teeth chattering. The by-product of the muscle contractions is heat.
Are you wondering about furry animals and the cold? A furry animal can get cold — just watch a Greyhound or Whippet being walked in Toronto in winter! How much fur or fat a creature has helps determine at what temperature it gets cold. That’s why seals, in general, are not bothered by the cold ocean, they’ve got thick layers of insulation in the form of blubber and fur.
Now just for fun, picture a polar bear and a mouse side-by-side in your room. The mouse is quite comfortable. But turn off the heat and it will shiver, or start running around like crazy to produce heat. At room temperature, the polar bear is panting and staying still. It’s hot! If you turn up the air conditioning and haul in some ice blocks, the bear will thank you.