The atmosphere is filled with minute particles called aerosols. These particles are of about the same size as the wavelength of visible light and scatter light at the short 'blue' wavelengths' a bit better than they do the longer-wavelength 'red' light. This means that as we look towards the sunset on the horizon, our path through the atmosphere intercepts lots of this aerosol material which preferentially scatters the blue component of the incoming sunlight out of our line of sight. The light is then reddened. As we look up towards the zenith over head, we are not seeing the sunlight coming directly from the Sun, but are seeing the light scattered by the aerosols at large angles to the line between the aerosol particle and the Sun. This light is blue because it contains little if any red light which is not scattered as well by the aerosols. The rate at which blue replaces red light as you go from the horizon to the zenith at sunset and sunrise can be used to determine the optical properties of the aerosols and their size distribution.