The function of the respiratory system is to exchange two gases: oxygen and carbon dioxide. Diffusion is the spontaneous movement of gases, without the use of any energy or effort by the body, between the gas in the alveoli and the blood in the capillaries in the lungs.