The molecules of air and other fine particles in the atmosphere are smaller than the wavelength of visible light. They scatter light of shorter wavelengths at the blue end than light of longer wavelengths at the red end.
Thus, when sunlight passes through the atmosphere, the fine particles in air scatter the blue colour (shorter wavelengths) more strongly than the red. The scattered blue light enters our eyes, and the sky appears blue.
But the sky appears dark instead of blue to an astronaut as the scattering of light does not take place outside the Earth’s atmosphere.