The complexity of breathing increases as does the need for efficiency. In quiet respiration , say whilst lying on ones back, almost all movement is diaphragmatic and the chest wall is still. This will increase thoracic volume by 500-700ml. The expansion of the lung deforms the flexible walls of the alveoli and bronchi and stretches the elastic fibres in the lung. When the diaphragm relaxes elastic recoil and abdominal musculature reposition the diaphragm again.
Deeper respiration brings in the muscles of the chest wall, so that the ribs move too.
We must therefore understand the skeleton and muscular system of the thoracic wall. The 12 pairs of ribs pass around the thoracic wall, articulating via synovial joints with the vertebral column - in fact two per rib. The ribs then curve outwards then forwards and downwards and attach to the sternum via the flexible costal cartilages. Costal cartilages are flexible. The first rib is rather different, short, flattened above and below and suspended beneath a set of fairly hefty muscles passing up into the neck, the scalene muscles.