Why do we need to sleep - and how this is related to consciousness?
Strange that for thousands of years people were puzzled by this simple question. Strange, since the answer is easy to find.
If you wonder why the sleep is needed, try not to sleep - and see what you will miss. Sleep deprivation degrades consciousness, time-, space- and self-awareness, thoughts coherence, memory - i.e. all cognitive and intellectual functions.
Thus, sleep is something our brain cortical neural networks require to avoid loosing its efficiency in computations. The awoken brain cortex activity is orchestrated by the reticular formation of the brain steam: the mechanism which creates our consciousness as a coherent thread of experience (one may compare that to the work of the OS system scheduler in a modern CPUs). Obviously, when run non-stop, the orchestration loses efficiency. Sleep resets it, allowing brain cortex to work in non-coherent mode for few hours (we feel that as sleep with no dreams, where we lose consciousness) - combined with "test drive" of REM sleep where the consciousness and coherence is present in a reduced form, receiving no external sensory input ("hallucinating" with dreams). This restores reticular formation "task scheduler" efficiency and supports our cognitive and intellectual functions after we awake.
Interestingly this shows that the sleep is not a property of the brain cortex, but rather of the brain steam, reticular formation, which has been present among animals much before humans, for hundreds of millions of years - in all species that do sleep (reticular formation is there in all chordata, starting from jawless fish). Thus, the sleep is a reticular formation reset: a reboot for the brain orchestrator.
The funniest part that some other phylogenetic branch of animals - cephalopod mollusks (octopuses, squids, cuttlefishes) - had independently acquired brain structure very similar to the reticular formation of chordata (and also named "reticular formation") - and, with it, ability & necessity to sleep!
QED, the puzzle of sleep is solved with what we already know today!