I was thinking more on the lines that we wouldn’t dream at all if there wasn’t some underlying function that aids survival, whatever it may be.
The science is fascinating, although I’m ten years out of date. What was known is that dreaming is essential to health and we all dream (or at least go into REM sleep) around six times a night. But changes to our long-term memory are chemically suppressed while we’re asleep so we can only ever remember waking dreams.
From the way regions light up on MRI scans, dreaming may have something to do with rebalancing the neural networks. If that’s correct then dreaming is essential to learning, not by rearranging memories but by optimizing the way they are processed to help automate the whole business. The theme of any remembered dream is then just a fairly meaningless by-product, skeptically speaking.