Mostly These fuel types define their anti knock qualities. Usually the engine knock is caused by fuel molecules breaking apart and detonating before the spark plug ignites the air fuel mixture (self ignition). The engine will be damaged if it is allowed to continue.
Designing an engine to reduce knock tends to reduce its efficiency and power output(low compression ratio). Using a fuel with good anti-knock properties allows designers to deliver more power and efficiency out of the engine by increasing a high compression ratio.
So theres no point using fuel with a higher octane rating than the engine was designed for. So long as the fuel doesnt cause engine knock, its good enough. Some cars are optimised for higher octane fuel, but can run on lower octane fuel by electronically detecting knock and delaying the spark timing, at the expense of power output and economy. And some cars can run on either 95 or 90 octane petrol. Turbocharged engines are recommended to be used high octane fuel then the turbo can increase its boost pressure.