There is obviously a very strong link between night time and sleep, and I don’t think it is a coincidence that our sleep patterns are more or less in line with the planet’s day and night cycles, so this is probably a good place to start looking for an answer.
If I am forced to speculate, I would guess that perhaps we started sleeping way before we were even mammals, perhaps even before we left the oceans. Fish do “sleep”, but it is not really sleep as we know it, it is more like a rest state. While I am not sure if it is true or not, I have heard rumors that sharks don’t sleep.
The ocean has something called the midnight zone, an area that light can not reach as it is so deep, I would be very interested to know if creatures living in the midnight zone require sleep or rest of any kind.
I would speculate, that the reason we sleep is something to do with the sun. We do ‘get’ vitamins and benefits from the sun, so perhaps, we run on a kind of “solar power”. Maybe humans use up the good stuff we get from the sun faster when we are awake, and if we are awake when there is no sun, we deplete the supply of good stuff, and so we eventually die from it.
I also think a very obvious reason to sleep for us humans, is brain size. You have to let the CPU cool down at some point.
If we ever find the answer, I think we will discover that it is for multiple reasons, maybe it is something very simple, like the ones who moved about too much at night in the dark would break their legs more often and be eaten more often.
The answer probably does have many reasons and explanations as to why it evolved, but I suspect it has something to do with sun light, and that this is probably one of the leading causes to evolve sleep patterns.
I would like to see if creatures in the midnight zone in the ocean require sleep, and if there is life on other planets and moons, such as europa, if they require sleep. Also it would be interesting to know if moles sleep, and if they do, how long have they been doing it for, what did they evolve from and will they still require sleep in a million years.
I am guessing, sun light and being a land animal are probably some of the main reasons.
… or, my speculation could turn out to have as much validity as the theory of water canals on Mars.