A Bump for Every Hair
Look closely at your skin and you will see that it is covered in fine body hairs, even in places that seem smooth at a glance. Each one of those hairs grows out of a tiny pocket in the skin called a follicle. Attached to the side of every follicle is a microscopic muscle. Its name is the arrector pili, which is Latin for "raiser of the hair." When that muscle contracts, it pulls the base of the hair sideways, making the hair stand up. The hair tugs the surrounding skin into a small mound — and that mound is the goosebump.
Two Triggers
Goosebumps are an automatic reflex, not something you decide to do. Two main triggers set them off. The first is cold. When your body senses a drop in temperature, your nervous system sends a signal that contracts these tiny muscles all over you at once, producing the familiar field of bumps. The second is strong emotion. Fear, awe, excitement, even a powerful piece of music can trigger the same reflex. The same nerve pathway runs in both cases, just set off by different signals.
Useful for Furry Animals
In animals with a thick coat, this reflex actually does something. When a cat puffs up to look bigger in front of another cat, or a dog's neck fur bristles at a strange sound, it is the same arrector pili reflex at work. The raised fur traps more air, which is a good insulator, so the animal stays warmer when it is cold. And against a threat, the fluffed-up coat makes the animal look larger and more intimidating to an opponent.
A Leftover Reflex in Humans
In humans, the same machinery still works, but our hair coat is far too thin for it to do much. The extra air trapped by our raised body hairs makes almost no difference to our warmth, and we certainly do not look any bigger or scarier with goosebumps. The reflex is essentially a holdover from a much earlier stage in our evolutionary history, when our ancestors were furrier and the same response had real survival value. The nervous system inherited the reflex and never lost it.
A Window Into the Body
There is something quietly fascinating about goosebumps. They are visible proof, on your own skin, that your body has wired emotion and temperature together with one tiny mechanism. A burst of awe at a piece of music can produce the same effect as stepping out into cold air. The bumps are mostly useless to us, but they are a small physical signal that the nervous system is doing exactly what it has been doing for millions of years.
Source
This article was written using information from Wikipedia.