In the early days of gasoline engines, they discovered two things right away.
1. The first engines knocked like crazy.
2. If you compress the fuel mixture before igniting it, you got more power.
Engines "knock" or "ping" when the fuel ignites before it is supposed to.
One of the strokes of a 4-stroke engine compresses the fuel-air mixture (by design.)
The problem of knocking (pre-ignition) had to be solved. Experiments with various fuels showed that heptane couldn't be compressed very much before it exploded on its own, but octane could be compressed a lot (relatively speaking) without making it ignite on its own.
One doesn't want to use pure octane, for cost reasons, and further experiments showed it could be combined with other fuels and still be compressed sufficiently. Today's low compression (8:1, for example) engines can run on about 87% octane and 13% something else. Heptane. Ethanol. Cheeseburgers. Maybe not cheeseburgers.
Cars with higher performance engines (some Cadillacs, Corvettes, etc.) which put out more power (and are therefore usually higher compression) require a higher octane-rated fuel to not knock (pre-ignite the fuel.) Knocking not only makes your engine have less power, it can damage your engine.
Many "muscle cars" of the 1960s and early 1970s compressed the fuel mixture to over 12:1. Zowie. 95 octane, please.
Octane is tested in the laboratory to arrive at a theoretical performance level, a test known as RON (Research Octane Number.) It is also tested under real life conditions - which show how a fuel behaves under a real load - with a test called MON (Motor Octane Number.) Then an average of the two is taken. The octane rating of the fuel thus tested is arrived at, as the gas pump at your favorite filling station will attest, by the above method, abbreviated (R+M)/2. There are underground tanks which separately hold each level of octane, and the hoses on the gas pump are fed by the proper tank. If the gasoline delivery truck driver hasn't been drinking.
We are not going to go into fuel additives, except for talking a little bit about lead, below. Sorry.
Early on, scientists discovered a second way to get more "free" power out of a gasoline engine besides compressing the air-fuel mixture before igniting it with a spark plug. That second thing was adding a substance called tetraethyl lead to the fuel. And so this was added to all gasoline. Unfortunately, after decades of doing this, a thin layer of lead covered planet earth. Lead is not particularly healthful to flowers, humans, and other living things. By the 1970s, leaded fuel had been outlawed in the U.S. There are only a handful of asshole countries in the world that still put lead in their gasoline, though some deny it. Here is the current list of countries the CIA says still allow leaded gasoline to be used. I want to "out" them here, for all the good it will do.
Bosnia and Herzegovina
(Source: Central Intelligence Agency, 2008)
Q. My car's user manual says it runs on unleaded regular gasoline. If I put premium unleaded instead, will it hurt my car's engine?
A. No. Why would it? You'll just waste money.
Q. Will I get more power if I use Premium fuel in my car that is supposed to use regular fuel?
A. No. Your little car isn't going to compress it any more than it did with regular gasoline. It can't.
Q. Is it ok to use regular gas in my car that is supposed to use premium gasoline?
A. No. You must use premium, if that's what your owner's manual says. Otherwise, your engine will knock. Do you remember why? Then why did you ask this question?
Q. Should I add lead to my gasoline?
A. Only if
1. You don't care about air pollution and killing things
2. Only if you have a desire to completely destroy your expensive catalytic converter in under five minutes.
There's that word catalytic again.