Your night-time dreams pull material from your memories.
Good memories can mean good dreams.
Bad memories can mean bad sleep.
The point of memory is to learn what not to do again. Or at least in less magnitude so you can get away with it the next time. When I was 15, I broke my wrist falling off a skateboard. It bothered me for months since 15-year-old me didn’t have the forethought to see a doctor about it.
I didn’t learn to stop doing things that came with risk. I learned to see a doctor when you’re hurt. To get a professional when you don’t know what to do.
I learned that doing things like skateboarding and playing sports made your worst problem a broken wrist. Becoming someone who avoids activity and risk brings problems that make you wish for something as easy to reverse as a broken bone.