Sunlight is secretly every colour mixed together. Blue light is the bounciest, so it ricochets off the air in every direction until the whole sky glows blue.
What's actually happening
Start with the surprise: sunlight is not yellow. It is every colour at once, blended so thoroughly that we call the blend "white". You only see the ingredients when something pulls them apart — a prism, a raindrop, or, as it turns out, the entire atmosphere.
Air molecules are thousands of times smaller than a wave of visible light, and tiny obstacles like that are picky about what they deflect. A light wave passing a molecule shakes its electrons, and the molecule re-radiates the wave in a new direction. Short, choppy blue waves shake those electrons far more violently than long, lazy red ones — about five to six times more. So as sunlight crosses the sky, blue light keeps getting knocked off course, bouncing molecule to molecule, until it finally reaches your eye from every direction at once. Look anywhere but at the sun and what you see is that rerouted blue.
A fair follow-up: violet scatters even more than blue, so why isn't the sky violet? Two reasons. The sun emits less violet than blue in the first place, and your eyes are much less sensitive to it. The sky is technically violet-ish; your hardware votes blue.
- 1Fill a tall glass with water and stir in a few drops of milk — that is your atmosphere.
- 2Shine a phone torch through it from the side, in a dark room. Looking at the glass from the front, the liquid glows faintly blue: short wavelengths scattering toward you.
- 3Now look at the torch through the glass. The beam itself looks orange — the blue has been scattered out of it, exactly like a sunset.