The sunset shown below took place on Feb 22, 2012 as high clouds help scatter the light of the setting sun into some of its component colors. These lovely colors are seen as the vibrant pinks, purples and deep blue’s here (discussion continues below image):
Sunlight is not really white, but a combination of many other colors which together appear white. These colors come in various wavelengths from the shorter blue and violet waves on one end to the longer orange and red waves on the other. Blue light is of the visible wavelength most easily absorbed and scattered by gas molecules in the atmosphere, making the sky shift to a "blue" appearance (The moon has no atmosphere so its “sky” is always black).
During the sunrise and sunset, light travels through even more of the atmosphere, and reaches you indirectly after the sun sinks below the horizon. Now, almost all of the blue and violet is scattered away and the horizon appears red or orange on a clear morning or evening. Dust, haze, smoke or water vapor all has an impact too.
Clouds change the equation and the most memorable sunsets often have a few clouds helping to scatter the light into amazing colors.
So the sunset above is a result of a complex interaction between:
No matter the science, it's certainly beautiful!