The color of the clear sky appears blue due to a phenomenon known as Rayleigh scattering. When sunlight enters Earth's atmosphere, it contains a spectrum of colors, ranging from violet to red. These colors have different wavelengths, with shorter wavelengths corresponding to violet and blue and longer wavelengths corresponding to red.
As sunlight passes through the Earth's atmosphere, the shorter wavelengths (blue and violet) are scattered in all directions by the molecules and particles present in the atmosphere. The scattering is more effective for shorter wavelengths because they interact more with the smaller particles in the atmosphere.
Blue light, being scattered more, is redirected in various directions and becomes visible to an observer on the ground from all parts of the sky. As a result, we perceive the sky as blue, especially when the sun is overhead. In contrast, the longer wavelengths (red and yellow) are scattered less, so they tend to pass through the atmosphere with minimal scattering, giving rise to the colors we see during sunrise and sunset.
In summary, Rayleigh scattering of sunlight by molecules in Earth's atmosphere is the reason why the clear sky appears blue.