Crotch and armpit hair provides a degree of lubrication for the skin. It's also thought these hairs retain body scents with sexual attraction functions.
Pubic hair is more likely for sexual display purposes, advertising when an individual has reached breeding age. Male facial hair is also believed to be for display, for intimdation of other males competing for mating rights over females, and establishing Alpha status within a breeding group. A more mature, seasoned male might be identifiable by his thick, full beard, a less experienced adolescent male by his thinner and patchy beard.
Scalp hair probably provides some temperature control for the brain, although why human hair grows to great lengths is less clear. It could stop at 6 inches and be just as effective as 24 or more inches. Since both sexes grow long hair on their heads, it wouldn't be for sexual differentiation.
Since very long hair soon becomes matted, and a home for unhealthy parasites, long scalp hair may force humans to perform mutual grooming. Other primates practice mutual grooming on their coats, but lacking other significant body hair humans may have evolved scalp hair instead to require this grooming function.
Primate studies have shown that mutual grooming aids socializing among breeding groups, and may have served early humans in a similar way.