One function of the foreskin was probably to protect the head of the penis from long grass, shrubbery, etc when humans wore no clothes, where evolutionarily our basic physiology and psychology are little different than our savannah-wandering or cave-dwelling ancestors tens to hundreds of thousands of years ago.
Also, the moist tip would facilitate quick penetration of a female, where lengthy foreplay and intercourse would be a survival disadvantage, since the risk to the copulators from predators and human enemies would be greater the longer they were engaged in sex.
Dr Guy Cox from The University of Sydney has suggested that the foreskin could in fact be the male equivalent of the hymen, and served as an impediment to sexual intercourse in adolescent primeval humans before the advent in our species of civilization and cultures . Way back then, Cox says the foreskin would have reduced "successful" sexual acts in those too young to adequately care for any offspring that might arise. With civilization, control of the sexual behaviour of the young by society made the physical mechanism redundant and society introduced circumcision to free the individual from the impediment of having a foreskin. Interestingly, the physical difficulties experienced by the uncircumcised may explain why the word for uncircumcised in Hebrew means "obstruction" or "to impede", so explaining the Biblical term 'uncircumcised heart' when referring to obstructionism.