Until the day nuclear fission can be safely done in an engine compartment, most engines still have to run on internal combustion. (aka Otto Cycle).
The petrol, being one of the 2 primary components needed for combustion, has an Octane Rating that affects the way that the engine runs. Because of the fact that it is not a constant speed engine, ignition advance is dynamically adjusted to reach the expected rpm.
The ignition advance or how much the ignition can be advanced, is largely dependent on the octane rating of the fuel used. ( and also dependent on existing condition/health of your engine )
When using a higher octane fuel, it means that the atomized air-fuel mixture in the combustion chamber can withstand a higher compression (during the compression stroke of the engine cycle) before it detonates and the combustion will cause the sudden volume expansion of gases and exerts the kinetic energy on the piston.