Goosebumps, or piloerection, serve a well-documented evolutionary function in thermoregulation by contracting muscles to trap a layer of insulating air near the skin across mammals.
Multiple retrieved papers explicitly confirm that piloerection (goosebumps) functions to provide thermal insulation by trapping air near the skin surface across mammalian species, including humans. There are no refuting papers.