Goose bumps are created when tiny muscles at the base of each hair, known as arrectores pilorum, contract and pull the hair erect. The reflex is started by the sympathetic nervous system, which is in general responsible for many fight-or-flight responses.
As a response to cold: in animals covered with fur or hair, the erect hairs trap air to create a layer of insulation. Goose bumps can also be a response to anger or fear: the erect hairs make the animal appear larger, in order to intimidate enemies. This can be observed in the intimidation displays of chimpanzees,[1] in stressed mice[2] and rats, and in frightened cats. In humans, it can even extend to piloerection as a reaction to hearing nails scratch on a chalkboard, listening to awe-inspiring music[3]; feeling or remembering strong, positive emotions (e.g., after winning a sports event)[4]; or to an intellectual or spiritual epiphany.
Piloerection as a response to cold or emotion is vestigial in humans; as humans retain only very little body hair, the reflex (in humans) now provides no known benefit.