One theory that’s gaining a lot of steam suggests it has to do with honing our survival instinct by stimulating potential threat scenarios in our subconsciousness.
The dreaming brain […] scans emotional memories. When it detects a memory trace with a strong negative emotion, it constructs a nightmare around that theme. The more traumatic the event, the more intense the nightmare. The brain’s system for detecting threats is sensitive and flexible: Anything the brain tags with a strong negative charge gets thrown into the threat bin and dredged up at night.
The argument goes that if we confront negative situations while we’re asleep, we’ll be better able to respond to them in our waking life, and in some cases that could ultimately prove to save our life if it’s put in peril.
Fascinating article. Definitely take a look.