White light coming from the Sun contains all colors of light from red to blue. The molecules in Earth’s atmosphere do not scatter much of the red light, but they do scatter a significant amount of blue light. This effect causes the blue sky.
These molecules scattering light also cause the Sun to appear redder than it really is. When the Sun is high in the sky the amount of reddening is small. However the Sun will still appear redder from the ground than from space because the atmosphere scatters some of the blue light.
When the Sun is low in the sky, much more of the blue light coming from the Sun is scattered away from the direct path towards our eyes. Hence the Sun will appear very red when it is low in the sky.
The same thing happens to the Moon. It often appears very red when it is low in the sky for the same reason.
Much of the beauty of red sunsets or sunrises comes not from the red Sun but from the red clouds just above the western or eastern horizon. Red sunlight reflecting off these clouds gives them the same rich red color the Sun has near the horizon. So in a spectacular sunset or sunrise the entire horizon is red.
The effect can increase when the Sun sets or rises over a large city. Pollution particles increase the effect by scattering or absorbing more blue light than red light.
Enjoy your next spectacular red sunrise or sunset and remember that Rayleigh scattering off molecules in Earth’s atmosphere causes the effect.