It’s hard to say why exactly we have nightmares. Sometimes they seem to be a way for our brains to process trauma or deal with fears we have. Most of the time, though, they’re just a thing that happens and is ok. 🙂
While we sleep our brain is still working at processing and sorting out all the information we took in during the day. Sometimes this causes us to dream and sometimes it causes us to have nightmares! I know they aren’t very nice but they are normal and generally nothing to worry about!