The light we see is a type of electromagnetic radiation. It's the part of the electromagnetic spectrum that human eyes sense. Sunlight is white light, which means it's made up of the colors you can see when they're separated in a rainbow or a prism. These colors form the visible spectrum. Each color has its own wavelength and frequency. Waves with a short wavelength, such as blue light, carry more energy than long waves like red.
Our atmosphere is made up of gas molecules. When light enters the atmosphere the molecules of the air interact differently with the different wavelengths. They have a significant effect only on light with a wavelength less than ten times the size of the air particles. That means that red, orange, yellow and green tend to continue the journey together without disruption.
However the air particles interact strongly with the shorter wavelengths of light such as blue and violet, scattering the light. This means that the light is briefly absorbed by the particles and then cast out in a random directions. It happens many, many times and the blue light fills the sky to give it its blue color. The selective scattering is called Rayleigh scattering, named after 19th-century English physicist Lord Rayleigh who discovered the phenomenon.
The more air the blue light passes through, the more often it gets scattered. If you look at the sky straight overhead you can see that it's a darker blue than elsewhere. This is because the light has traveled to your eyes by the shortest path, and undergone the least scattering. Near the horizon the blue is pale because the light has been scattered many more times in all directions.
Having shown how Rayleigh scattering gives us a blue sky, you may be surprised to learn that it also gives us red sunsets and a reddish Moon during total lunar eclipses. At sunrise and sunset the Sun’s light is taking the long path through the atmosphere. And during the totality of a lunar eclipse, there is indirect lighting from sunlight in the Earth's atmosphere. Since the blue light gets scattered, it leaves the redder colors to travel through the atmosphere. Some of this light shines on the Moon, often making it look as though it's covered in blood.