What causes morning wood?
Sometimes men wake up with an erection in the morning. Why does this happen?

Shortly speaking: REM (Rapid Eye Movement) is one phase of sleep. During this phase, we dream and some of our neurotransmitters are shut off. This include norepinephrine, which is involved in controlling erections. Norepinephrine prevents blood from entering the penis (preventing the erection). In absence of norepinephrine—during REM phase norepinephrine is absent—blood enters the penis, leading to an erection. This phenomenon is called nocturnal penile tumescence. Such erections typically occur 3 to 5 times a night. A related question concerning similar erections in women can be found here.

High pressure in the bladder may also lead to a "reflex erection". This erection allows for preventing uncontrolled urination. The drawback is that when in the morning one has an erection and can't wait to pee it might get hard to accurately target the toilets!

This video is also a nice and easy source of information on the subject.

Is it bad?

(Reading my "note" below, you have edited your post to get rid of this question, thank you)

It is perfectly healthy you don't have to worry about that. These erections are even thought of as contributing to penile health. At the opposite end of the spectrum, the absence of erections during the nights are an index of Erectile Dysfunction (E.D.).

Note

Be aware that medical questions are often considered off-topic on this site. Asking "is it bad?" turns your question into a medical one. Health-related questions (but not personal health) should be asked on health.SE