Too early and the piston, which is compressing the air/fuel charge, will meet gas expanding from the explosion, causing excessive pressures.
Too late and there will be a waste of compression and hence output.
The trick is to find the optimum point to fire the mixture. This is typically at the point on the torque curve called ‘mean best torque’ and is the maximum torque output, against varied timing.
Typically, the spark is fired 10-30° before the piston reaches ‘top dead centre’ (TDC), the very top of its travel. The spark advance will increase with engine speed, because the mixture will burn at roughly the same rate, irrespective of engine speed, and therefore needs to be ignited earlier to achieve maximum pressure at the same point in the engine cycle.