Erectores pilorum (singular Erector pili) are tiny muscle fibers attached to each hair follicle, which contract to make the hairs stand on end, causing goose bumps. They exist in most mammals including humans.
Erectores pilorum are smooth muscle, not skeletal muscle, which explains why humans cannot voluntarily give themselves goose bumps. In other animals with more hair than humans, they serve an important function — they raise the hairs so air gets trapped between them, providing a layer of insulation to keep the animal warm. Some animals also contract their erectores pilorum when they are cornered, in order to appear larger and more threatening. A prominent example of this function is the porcupine which uses erectores pilorum to raise its quills when threatened. Although humans' erectores pilorum also contract in response to cold or arousal, they are vestigial because humans do not have enough hair to make them effective.
Cross-section of all skin layers.