Compared with most mammals, humans actually have very little hair. Most of our bodies are covered with inactive follicles leftover from past times when we did still have a fur coat. On our heads, however, we still grow lots of thick hair. Not only that, but also it grows unusually long - far longer than is normal for mammals or even for us.
Typically, to be useful in keeping the body warm, hair needs to be around one or two inches long. But on the human head, hair can grow several meters long. How long it actually can grow is called the terminal length and this can vary greatly from one individual to another. Typically, adult women have a greater terminal length than adult men on average. This, however doesn't show easily because in most cultures men keep their hair significantly shorter.
Why do we have so much hair on our heads?
Let's assume that evolution was not influenced by our centuries of cutting and styling of the hair on our heads. So the completely natural look would be for both men and women to have hair hanging down their backs - probably reaching about the middle of our backs on average. Now anyone who has grown their hair this long will testify that it can be quite a hassle to say the least. Irrespective of beauty or style, long hair is hard to groom and maintain manageable. Very long hair is also extremely impractical for any kind of labor. And beyond a certain length it does little to keep you warm compared with just having a thick coat of short hair all over.
So what is the purpose of such long hair? Does there need to be one - you might ask and the answer is definitely yes. For any characteristic like this to evolve, it must have been useful at some stage. So what might that purpose have been? Nobody knows with certainty but there are some possibilities being speculated on:
Protection from Sunlight. As humans started to walk upright, our heads and shoulders were far more exposed to direct sunlight. Long hair could certainly serve to protect from sunlight. This is also a possible explanation for very tight curly hair or Afro hair in humans from hotter countries as such a hair texture will likely be more effective in shielding the sunlight.
Social Status. Humans are social creatures and how we relate to one another is an important aspect of our species and this has likely been the case before civilization. Today and throughout recorded history, hairstyles have been a very important factor in our lives. They serve to express status and health. Hairstyles have been used to convey membership of classes and cutting or shaving hair was used as a form of punishment or humiliation but also as a sign of breaking away from society.
A Crest for Partner Attraction. Due to the fact that men and women have noticeably different hair, gender codes in hair styling have emerged and created features of attraction between the sexes. While beautiful hair is generally considered very desirable in both genders, with women this is far more the case. Also, long hair is considered far more attractive on women than short hair. While on men, long hair is usually not seen as attractive. This might very well be down to modern social norms though as many cultures throughout history have had entirely different norms.
The Horsetail Purpose. Just as a horse's tail, long hair on humans could serve as a means for brushing away mosquitoes and flies or other intruders. This is enforced by the fact that our back is the only place we can't easily reach with our hands.
A handle for babies. There must be a reason for why women grow longer hair than men. One speculation is that it served as a means for babies to hold on much like the baby chimp clings to its mother so she has her hands free.