There are a number of theories.
One of the most interesting recent ones is that it keeps us out of trouble.
Once you have met your daily requirements - food, water, shelter etc. additional time being out and about increases your probability of meeting a predator, falling off of a cliff or generally meeting a situation to reduce your chance of being killed prior to a sucessful reproduction.
Sleep therefore evolved to give us all a strong need to tuck ourselves out of the way until our body needed something more.
Not saying this is the right explanation - but it is interesting