Light is made up of electromagnetic waves. The distance between 2 crests in this wave is called the wavelength.
White light contains all the colors of the rainbow. All the colors in white light have different wavelengths. Red light has the longest wavelength. Red light's wavelength is larger than oxygen atoms are big. When red light passed through the atmosphere, its long wavelength causes it to pass through the atmosphere without being scattered/spread around. Blue light has a much, much shorter wavelength than red light. the wavelength of blue light is shorther than oxygen atoms are big. Many of the blue light waves from the sun collide with the oxygen atoms. When such blue light waves try to go straight through an oxygen atom, its light is scattered in all directions because of this collision. This scattered blue light is what makes the sky blue. All other colors (with longer wavelengths than blue light) are scattered too. Blue light's short wavelength causes it to be scattered the most. (The shorther the wavelength of the color, the more that color gets scattered by the atmosphere) Actually, violet has the shortest wavelength of all colors. Violet is scattered even more than blue light. However, our eyes are much more able to see blue than violet, therefore we see the sky as blue. Very little visible light is absorbed by the atmosphere.