We have nightmares because our brain is running simulations to put us in jeopardy to see what we'll do or to acclimatize us to that idea that something bad could happen. It's just how human beings are wired because the entire time we were evolving we had to jump quick or the leopard would get us or whatever it was. It's Darwinian.
James Cameron