The light we see from the sun is made up of a rainbow spectrum of colors from red through blue to violet. As light passes through the Earth’s atmosphere, it hits small gas molecules and particles in the air and gets scattered in different directions. This is known as Rayleigh scattering.
As blue light has more energy than, say, red light, the blue light component of sunlight is scattered more strongly in the atmosphere. So, what we see when looking up is an excess of the higher energy blue light being scattered compared to other lower energy colors, and hence the sky appears blue.