White light from the sun is composed of all the colours that make up the rainbow. Light is an electromagnetic wave, and these colours are each characterized by their wavelengths.
Visible spectrum is the observable region of the electromagnetic wave which is visible to human eyes. In electromagnetic spectrum, the visible region ranges from IR region (red, 700nm, longer wavelength, lower frequency) to UV region (violet, 400nm, shorter wavelength, higher frequency) and after this range, human eye is unable to see the rest of electromagnetic waves. Colours in the visible spectrum have different wavelengths. Red light (longer wavelength, 0.7 microns) to Violet light (shorter wavelength, 0.4 micron).
When light comes from the sun, all the light waves of different wavelengths travel through empty space. Sun sends the beam of light which carries about every wavelength from X-rays to Radio waves on its 8 minutes trip to earth. The earth’s atmosphere trims the light waves into a narrow range of wavelength of visible region. Since the light appears white, as a mixture of all the wavelengths from violet to red, each colour represents as a light wave with its respective wavelength.
Now, it is evident to ask, why the sky appears blue during daytime. Our atmosphere is composed of different gases like CO2, O2, N2, Argon, traces of He, Ne, Kr, H, methane and water vapor. Including these gases, atmosphere also contains dust and dirt.
Modern time Physicist named, John Strut Rayleigh figured out that light rays get scattered when it travels in the atmosphere and the amount of light that scatter depend on 1/4th power of wavelength. Amount of light waves scattering depends strongly on the size of particle (through which light wave interact) compared with the wavelength of light.
Particles in atmosphere that are small compared to light particles, scatter the blue light (light wave of shorter wavelength) more strongly than red light (light wave of longer wavelength). When light is moving through cloudless atmosphere, on the other hand, our perception of it is very wavelength-dependent. The small gas particles in the atmosphere scatter blue light about 16 times as efficiently as they scatters red light, an effect called Rayleigh scattering. This is why the sky is blue.
Red light has longer wavelength so it scatters less and likely to wash away the air molecules present in the atmosphere. Blue light has shorter wavelength so it interacts more with the air molecules present in the atmosphere, thus scatters more. So blue light scatters much more than red.
Why sky appears in reddish or other warmer colours during sunrise and sunset?
Sun is actually not blue, red or yellow. It is actually white, a mixture of all wavelengths of light as we know. At sunset and sunrise, sun is a lot lower in the sky and sunlight has to travel through a lot more atmosphere to reach your eyes. That means, blue light has lot more to scatter in different directions in the atmosphere and since red light does not scatter much in the atmosphere, it travels throughout the atmosphere to reach our eyes. This is the reason the sky appear reddish or in other warmer colours to our eyes during sunset and sunrise.