The diaphragm contacts and moves down. The intercostal muscles between the ribs contract. This causes the ribcage and the sternum to move up and out. The thorax increases in width from back to front. This results in the pressure within the thorcic cavity decreasing. As there is a lower pressure within the thorax and an increased area within the thoracic cavity the lungs expand. The lungs expanding leads to air from the external environment being brought into the lungs, down a pressure gradient, through the bronchi, broncioles and to the alveoli. It's in the alveoli that gas exchange occurs and oxygen from the air moves into the capillaries.