One function of sleep may be to clean up waste accumulated while awake. To run the cleaning process while awake may require more active energy consumption and was a way of conserving total energy in our evolutionary past when activity wouldn't be very productive anyways.
http://www.nih.gov/news/health/oct2013/ninds-17.htm