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