Light energy is similar to water in the ocean: it travels in waves. Some light travels in longer waves, while other light travels in shorter waves. Blue light waves are much shorter than red light waves.

All light travels in a straight line unless something gets in its way and either bends it, reflects it, or scatters it.

Sunlight that reaches Earth is quickly scattered by the gas molecules in our atmosphere. Since blue light waves are shorter than the others, they are scattered more easily. This is why we see a blue sky during the day.

Why does the sky have different colors at sunrise and sunset?

At these times, sunlight has to go through more of the atmosphere to reach you. This means the blue light is scattered even more. The red, orange, and yellow light however, is harder to scatter, and so it passes straight through the atmosphere, making a sunset.