Highlights ► We present a theoretical review of sleep with a special focus on pontine-geniculate-occipital waves and what they tell us about sleep and consciousness. ► We review the nature and purpose of sleep in terms of protoconsciousness and predictive coding, using the free energy principle. ► By combining these theoretical perspectives, we discover answers to some fundamental questions: such as why is homeothermy suspended during sleep? Why is sleep necessary? Why are we not surprised by our dreams? What is the role of synaptic regression in sleep? ► In brief, we show that the brain can optimize itself during sleep by minimizing the statistical complexity of its model of the waking world. ► The implicit optimization processes are remarkably consistent with the known neurobiology of sleep and provide testable predictions about its functional anatomy.