Our skin is responsible for ensuring that, when our surroundings get too hot, our body temperature doesn't spike up to unhealthy levels. Likewise, when our surroundings get too cold, our skin plays a role in preserving body heat so that our temperature doesn't drop below a certain level. It is important that we maintain an optimum temperature for the enzymes in our body (around 37 degrees celsius). If it's too hot, our enzymes will denature and will become inactive/lose their function. If it's too cold, the enzymes will too become ineffective (their function will slow down too much).
When it's too hot:
Sweat glands will produce sweat. Heat is retained in the liquid and thus will be lost when sweat evaporates from the surface of our skin. The hairs of the skin will lie flat so as to not trap any insulating air. Vasodilation occurs increasing bloof flow to the surface of the skin so more heat is lost via radiation.
When it's too cold:
The hairs on the skin will stand up, allowing them to trap pockets of insulating air, thus retaining heat. Vasoconstriction will occur, allowing less blood to reach the surface of the skin, so less heat is lost. Shivering will occur. Shivering is the vigorous movement of muscles, requiring them to respire more and thus produce more heat as a result.