Why do our eyes close when we sleep? Is it to relax our eye muscles? How can it be explained from an evolutionary point of view?
Our eyelids close when we sleep probably for the obvious reason that it prevents the sclera and cornea from drying out, becoming accidentally scratched (such as blowing dust) and allowing oxygen diffusion from the inside of the eyelid (to the sclera and cornea). Fragile corneas are a requirement for our vision. Thick corneas are much less fragile but then attenuates more light.
1) blinking requires muscle movement which sort of defeats the purpose of resting
2) closed eyelids offer much better protection than periodic blinking
3) if you can blink, you have eyelids.
There's definitely something to the fact that eyes work better when they are closed periodically and don't work well when they are open constantly, but there is another angle to this topic.
I think its worth adding that not all animals sleep with their eyes closed.
This is because some animals sleep with only half of their brain at once. Ducks, some birds, aquatic mammals like whales dolphis and seals engage Unihemispheric sleep. In Unihemispheric sleep, half the brain is asleep and the other is awake. Not necessarily fully awake, but enough that one eye is open and watching for predators or other threats.
One might ask - didn't we all have predators and threats? Why don't we all sleep half the brain at a time? The answer is not clear, but it appears that unihemispheric sleep is not a trait that is maintained easily. Very few animals really have the ability. As such there must be some advantages physiologically to closing both eyes at once and experiencing total sleep. Once the threat is not so great from being sleeping prey, animals start to close both eyes pretty quickly.
Tears contain an important hormone that kills bacteria. Closing eyelids during sleep allows a prolonged contact between the cornea and tears killing resistant bacteria in the process. The action of the tears during blinking is not sufficient to completely get rid of the foreign bodies in the eyes. Closing eyelids gives the tears a capacity to accumulate forming a film of moisture above the cornea and acqeous humour. This has many important uses. It allows dust particles to dissolve and be eradicated when the tears flow out of the eyelids. This partially explains the residue that is seen on the cheeks when people wake up in the morning in addition, of course, to the sodium and potassium salts in the tears. The other importance of the film of tears accumulated on the eye is to help keep the acqeous humour moist. This has a great effect on how the lens receive light and also on the overall refractive index of the eye as system.