I've seem several articles claiming that sleep is akin to the usual proccess of hard drive defragmentation, however for your brain. This process allegedly prunes synapses/memories and reconsolidate memories.
You can find several versions of this claim:
(..) So the brain must periodically clear out the synaptic underbrush—analogous to “running a repair-and-cleaning program on your computer to defrag the hard drive,” says psychologist William Killgore of Harvard Medical School. http://time.com/4737596/sleep-brain-creativity/
(...)A defrag consolidates the same data into a more logical order. Defragmentation is a taxing chore for the computer, so many people schedule it to happen overnight. In the same way, sleep may serve to reorganize and reconsolidate memories. http://blogs.discovermagazine.com/neuroskeptic/2011/08/21/is-sleep-brain-defragmentation/#.XIg-xbjQ-Uk
(...) During sleep, your brain goes into a cleansing and restorative mode. It washes away all of the unimportant and unnecessary thoughts and memories to maintain space for all the memories you need to function, and reorganizes the free space for new memories you’ll make tomorrow. In a nutshell, your brain gets refreshed when you sleep. And this process is so important because it aids in the healing of dementia. http://handsoffmybrain.com/2018/09/defrag-your-brain-with-sleep-but-what-do-you-do-if-you-cant-sleep
Does the brain do something similar to defragmentation while we sleep, by cleaning synapses and "washing away" unimportant thoughts?