
not everything that happens has an evolutionary advantage, it just means that it didn't have an evolutionary disadvantage. having a big complicated brain was an advantage. the fact that our big complicated brains fire off random signals while we sleep that present as images and stories is a side effect.
Coming from your handy psych master student. Dreams actually have tons of meanings! There are a ton of different theories but the main one people tend to stick with is your dreams are a presentation of how you are feeling. It’s nothing evolutionary really. The brain is a lot different than physical evolution. Brains obviously develop with evolution as well but very differently! :)