During sunrise and sunset, light has to travel a longer distance to reach the observer. Loss of energy due to scattering is more for high-frequency waves. Longer wavelength wave has minimum loss due to scattering and can travel long distance. Red color has a longer wavelength, and its intensity reaches the observer more compared to other colors. Hence the sun appears red during sunrise and sunset.