Morning wood is actually just the leftovers from what happens at night. Nocturnal penile tumescence (NPT) is a natural part of the male sleep cycle, occurring most frequently during the REM cycle in which we dream. The average night of sleep for a male between 13 and 79 years old involves 90 minutes of erection, or about 20% of overall sleep time. Females also experience a related vaginal lubrication during their dreaming states, but neither phenomenon is related to sexual activity during the day. The fact that this happens can also be a contentious legal issue. You can read more about that in this article.
NPT is actually helpful when trying to determine the cause of erectile dysfunction. When a man’s erectile dysfunction is psychological in origin, NPT still occurs. Doctors can use electronic monitoring on a sleeping patient to see if they have nighttime erections (WebMD)