In extremely simplistic terms, advancing the timing so the spark occures before TDC gets the mixture expanding so it can exert the optimum force to move the piston down in the bore. This optimum setting is usually just before detonation (pinging). Increasing the advance beyond this optimum setting sets up even higher pressure conditions that cause detonation to occur. This can be countered with higher octane fuels or booster additives that increase the fuels resistance to detonation. With higher octane you could run a bit more timing advance before you run into detonation again.