The blue color of the sky is due to Rayleigh scattering. As light moves through the atmosphere, most of the longer wavelengths pass straight through. Little of the red, orange and yellow light is affected by the air.
However, much of the shorter wavelength light is absorbed by the gas molecules. The absorbed blue light is then radiated in different directions. It gets scattered all around the sky. Whichever direction you look, some of this scattered blue light reaches you. Since you see the blue light from everywhere overhead, the sky looks blue.
As you look closer to the horizon, the sky appears much paler in color. To reach you, the scattered blue light must pass through more air. Some of it gets scattered away again in other directions. Less blue light reaches your eyes. The color of the sky near the horizon appears paler or white.
Sunlight hitting the earth's atmosphere is a composite of electromagnetic radiation at different wavelengths (or frequencies if you prefer - just remember that they are inversely proportional). A portion of that radiation is in the "visible spectrum" of human evolved eye-sensitivity (other living creatures can see a greater spectrum or are more sensitive to a particular part of the spectrum - due to evolutionary pressures) . The air in our atmosphere acts like a huge prism - and due to some complicated physics - this prism effect scatters light of lower (shorter) wavelengths (higher frequencies) much more than higher (aka " longer") wavelengths. Remember, in the visible spectrum as defined by human eyes - and the atmosphere only allows electromagnetic radiation of certain wavelengths to pass: "the optical window". You see blue because blue is actually high frequency em energy that scatters best by our atmospheric prism made of air at "blue" electromagnetic frequencies. The human brain has evolved to assign the "stimulation" of em radiation at specific frequencies the perception of color. Evolution has developed special cells in our eyes that can discern between different em frequencies - which we perceive as the sensation of the full spectrum of color.