Good question! I suspect that many other readers have wondered this as well. In fact, most people experience these twitches and some have them frequently when falling asleep, although not everyone realizes they are doing this. Sometimes, the twitches are noticed only by the person lying next to them.
Called sleep starts or hypnic jerks (from the Greek hypnos- meaning sleep), these sudden movements of the legs or arms are considered normal. However, no one knows exactly why this happens. One theory involves the reticular activating system or RAS, a collection of nerves within the brain and their connections throughout the body that helps control our level of alertness. Jerking movements may happen when some nerves in the legs or arms "misfire" as the RAS helps make the transition between wakefulness and sleep.
Another theory suggests that these twitches are a more basic protective reflex. As we fall asleep, our muscles relax and eventually become quite loose. Our brain may interpret this overall relaxation as a sign that we are falling down, and then respond by telling the muscles to tighten up to keep us standing. This theory certainly seems consistent with the fact that many people, myself included, describe the sensation of falling down just before waking up with a hypnic jerk.
Although they can be startling, occasional hypnic jerks are nothing to worry about. Keep in mind that hypnic jerks, like many other sleep problems, (for example, sleep walking, sleep talking, nightmares, and night terrors) tend to happen more often when someone is overtired. Even when we are terribly busy, we always should try to get enough sleep!