Part of the light passing through the air is scattered in all directions by the molecules comprising the atmosphere. The wavelengths of visible light are larger than molecular sizes, and the scattering is strongest for wavelengths of light closest to sizes of molecules.
Credit: University Physics Volume 2 by OpenStax, openstax.org, licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Exercises adapted: converted to Kosoma's format, maths re-typeset, some exercises split into parts. Source commit db44eb99e9aa1d918fd8cf182f82ccdece9c7b11.