There may be several reasons for morning erections. It's possible that you were having a sexy dream. It's possible that you were just having an erection for no reason like you do during the day.
It is also said that a full bladder will press on your prostate, causing an erection. I've even heard it said that it's meant to actually hold in your urine because it is difficult to urinate with an erection.
Another theory is similar to what Llewellyn said about penis health. The penis, like any part of the body needs oxygen, and erections are the bodies way to ensure the penis gets enough blood, and therefore oxygen. Incidentally, oxygen levels are higher at night which may lead to more erections.