https://super-memory.com/articles/sleep.htm
The hippocampus acts as the central switchboard for the brain that can easily store short-term memory patterns. However, these patterns have to be encoded in the neocortex to provide space for coding new short-term memories. This complex process of rebuilding the neural network of the brain takes place during sleep. Unlike rest or conservation of energy, this highest feat of evolutionary neural mathematics requires the brain to be shut off entirely from environmental input (in most animals)