This is because of Rayleigh scattering, when sunlight passes through the atmosphere it scatters sunlight into colors, with blue generally being the most prominent of them. At sunrise and sunset the most prominent color is orange and yellow, and at night due to minimal sunlight there isn't any prominent color.