We humans spend about one third of our lives asleep. For much of human history, people have been more vulnerable to enemies and predators while asleep, but yet everyone sleeps and cannot help but do it. So, there must be a good reason for sleep, perhaps an evolutionary advantage.
One reason for sleep is to rest the brain and body, but yet the brain is highly active during sleep. Freud thought that one purpose of sleep was to grapple with negative thoughts buried in the unconscious via dreams. Another theory was that the brain lopped off unused synapses (nerve connections) during sleep to improve its health, much as pruning dead branches from rose bushes improves their health. Sleep also helps consolidate memories and learning.