Q1/Q2 's main purpose is temperature compensation of Vbe of the output drivers. In order for this to work effectively, they must be connected to a common heatsink. so the diode drops cancel out within 1% and prevent thermal runaway. The other answers are also correct but the main purpose is to prevent thermal runaway with compensation.
= added =
To prevent thermal runaway with the Q3 & Q4 becoming biased at the same time, you want the DC base current constant over temperature and supply variations. We know Vbe has a NTC or negative temperature coefficient, so Vbe drops with rising T so a fixed voltage bias would result more DC emitter current which may increase T and thus a positive feedback thermal loop called runaway. Hence the diodes Q1/Q2 will produce a similar voltage to Q3/Q4 as a function of temperature. The differences include the ESR of Vbe and the junction temperatures. ( Q1 vs Q3 & Q2 vs Q4 ) Ideal circuit design will minimize these differences.
The self-destructive runaway can get triggered by low headphone resistance at high volume levels causing thermal rise but be ok otherwise. The output current limiting resistor is designed to reduce that risk.
Given that the Q3/Q4 also has an emitter resistor, the risk for thermal runaway is also lowered but the amount of crossover distortion is increased with frequency due to reduction in loop gain.