Yeah, you've woken up with it, or been woken up by it. But despite what you might think, morning wood isn't caused by dirty, sexy dreams. It's actually just nature's way of protecting your penis.
While in REM sleep, your body turns off some neurotransmitters to regulate body functions. And one of those neurotransmitters, Norepinephrine, is the one in charge of stopping erections. Basically, when REM decreases the Norepinephrine levels, testosterone is free to pump blood into the area and cause your sleep erection. In addition to making for wonderful school jokes, morning wood is actually important because it pushes extra oxygen into the region, and helps keep your penis healthy and functional.
Alternatively, if you've got a full bladder when you go to bed, it can bump up against your spine and automatically give you an erection to stop you from wetting the bed.
So there you have it! Sleep erections are like defragging your penis. [ASAP Science]