The reason this works is that you have a biological clock that responds to sunlight (specifically the blue light) exposure. This is the same principle behind the common advice to not be on a screen too late as it emits blue light.
This will also help you feel more awake in the mornings and many participants reported they had improved mood when they were exposed to sunlight.