What we were taught
Remember the science teachers saying sunlight is white? Is it though? Is the Sun yellow? What is even “colour”? Why do we perceive different frequencies of the electromagnetic spectrum as different colours?
To be honest, no one knows why these frequencies show us the exact colours they do, but what we can do is to imagine how it so happened in Humans, or life on earth in General.
What we weren’t taught
The Sun emits electromagnetic radiations of various frequencies, the visible spectrum is a tiny portion of these frequencies. There are three mathematical models that predict its peak frequency or “colour” based on its temperature. One predicts infrared: 343 THz, another predicts violet, and the third predicts Green. In either case, the peak frequencies are very close to or lie inside the visible spectrum. (Source) What’s that? :-
When the eyes of our ancestors saw that the peak radiation of the sun lies in this range, they adapted to it being the primary focus for them to recognize, and so adapted for these wavelengths to be visible. The main aim back then was to find where the sun is, finding light meant food for the new water animals, as it would be where the plants grew. It meant navigation and differentiating day from night. Slowly and steadily the functions evolved as our needs evolved, and as life moved from water, to land, and to air.
One may say that we see the colours as they are just because the Sun emits radiation whose peak frequency is in the visible spectrum. Who knows if we had evolved near a Red Dwarf, we might have seen different colours: more around red, maybe we’d never be able to see Blue, but we could see infrared frequencies as different colours. New colours altogether, now that is something to think about!
Why does sunlight appear yellow? The atmosphere scatters most blue and green light, which is why the sky is blue and the sunlight appears yellowish orange. Don’t believe me? Watch the sun from the ISS in all its white glory.