Why do you twitch right before you fall asleep?

Part of sleeping. The falling sensation or twitch is known as a hypnagogic myoclonic twitch. As your muscles begin to relax in preparation for sleep, your brain senses these relaxation signals and misinterprets them, thinking you are falling down. The brain then sends signals to the muscles in your arms and legs in an attempt to jerk you back upright.
Possibly abnormal. Recently jerks have been tied to sleep anxiety, fatigue, and discomfort. People having trouble sleeping or can’t get comfortable in bed appear to experience the sensation more often. It is especially more common with people who are trying to fight falling asleep or have deprived themselves of sleep for more than 24 hours.