There’s an hypothesis that states we dream so we don’t lose visual processing neural connections. Similar to what happens in blind people: visual processing neurons are recruited to other sensory tasks due to lack of stimulation. My ed. guess is that dreaming probably serves multiple purposes