Your brain is run by chemical reactions. Those reactions can happen very fast or more slowly, but they all take time. So, while a given reaction is ramping up or winding down, you’ll still feel it a little bit, but maybe not all the way.
When you’re asleep, your brain is full of chemicals that make you unconscious. When you wake up, those chemicals are wearing off. But they are big doses of sleepy-chemicals that last for hours on end. They don’t shut off immediately.
It kinda makes sense that you feel a little groggy when you have just stopped being asleep – you’re basically coming off some really strong drugs that are designed to have you on your ass for hours! It takes a few minutes for those chemicals to clear out of your system.
To add a little detail since the ELI5 part is done, part of the process of cleaning (yes, physically cleaning) your brain while sleeping involves flooding it with spinal fluid. This is slightly inhibitory of normal functions, so if you wake up during one of the cleaning cycles, you will have difficulty thinking straight until it finishes draining and readjusts. There are a lot more factors involved, but this is one of the coolest ones.
Latest Answers