We've all had the experience of waking up in the morning, looking at the clock and realizing you literally woke up one minute before your alarm was going to go off. But there's a perfectly reasonable scientific explanation for this phenomenon.
At the center of a person's brain is a clump of nerves called the suprachiasmatic nucleus. This group of nerves is super important since they control your blood pressure, your body temperature, and your sense of time. They also control your internal clock, which scientists call the circadian rhythm. Your body works most efficiently when it follows a routine, so your circadian rhythm basically makes you feel sleepy and wake up at the perfect times for your body to be at peak performance.
To do so, your body creates a protein called the PER. PER falls as the day progresses until it gets so low your blood pressure drops, your heart rate slows and you get sleepy. Then when you're about to wake up, your body begins generating PER. Your body also releases hormones to reduce the stress of waking up from sleep.
All of this means that your entire body is involved in making sure you fall asleep at a certain time and then wake up at a certain time. If you follow a set schedule every single day, your body will also adapt to that schedule. So your body will begin the process of falling asleep when it's close to bedtime, and will begin the process of waking up when it's close to that time as well.
Essentially, your body is more prepared for you to wake up than your alarm clock is. So when your alarm is about to go off, your body is already in the process of waking up, which is why you sometimes beat your clock by a couple of minutes.
In fact, your body doesn't like your alarm clock. Your body is meant to undergo a natural process to prepare you to wake up. But an alarm clock wakes you up before all your systems are ready to start the day. That's why you often feel groggy in the morning after your alarm clock has gone off, even if you got a solid eight or more hours of sleep.
Unfortunately, we don't think too many bosses will accept, "My circadian rhythm wasn't ready until 9:30 this morning," as an excuse for coming into work late.
(h/t Mental Floss)