This is the small hairs standing up on our skin. This can trap small pockets of air which can act as an insulator and trap in heat. As our bodies can only react in certain ways it also happens when we are scared.
Its a response related to certain kinds of stress. So if we are cold our hairs stand on end in a response that we probably used to use to preserve heat. The response is also similar through fear, excitement, nerves etc. Some animals would also use a similar response as a protective mechanisms to try and warn off predators.