Its mainly because of scattering of light..if an observer in ground sees the sky as blue due to the scattering of light by air molecules present in the atmosphere. thus the earth wouldn't be blue if it doesn't have enough O2 and N2 molecules in its atmosphere. The scattering depends on the characteristics of gaseous molecules in atmosphere....:)