The sky changes colors primarily due to a phenomenon known as Rayleigh scattering. Rayleigh scattering occurs when sunlight interacts with the molecules and tiny particles in the Earth's atmosphere.
During the day, when the sun is high in the sky, the blue light from the sun is scattered more by the atmospheric molecules compared to other colors. This scattering phenomenon causes the blue light to scatter in all directions, making the sky appear blue to our eyes.
During sunrise or sunset, when the sun is near the horizon, the sunlight has to pass through a larger portion of the Earth's atmosphere. The increased path length leads to more scattering of the shorter wavelength blue and green light, which is why the sky often appears to have shades of red, orange, and pink during these times. This is because the longer wavelength red and orange light is less affected by scattering and can reach our eyes more directly.
The presence of particles, such as dust, pollutants, or water droplets in the atmosphere, can also influence the colors we perceive in the sky. These particles can scatter light in different ways, leading to variations in color and intensity.
Additionally, weather conditions, such as clouds, can affect the scattering of light and result in different colors and atmospheric phenomena, such as a gray or overcast sky.
It's important to note that while Rayleigh scattering is the primary reason for the sky appearing blue and the color changes during different times of the day, other factors and atmospheric conditions can contribute to variations in sky color as well.