I had a discussion recently with my daughters about the importance of sleep. The brain moves memories to long term, or discards them as it sees fit, during sleep. Without sufficient sleep the brain may discard memories incorrectly or it might file memories in long term that need to be retrieved more quickly. Getting sufficient sleep reduces these risks.
Here’s an interesting video on the topic.