There are two types of octane quantifiers, the RON (Research Octane Number) and the MON (Motor Octane Number). The RON is the level of the fuel's pre-detonation or "knock" resistance (compress a fuel quickly and hard enough and it will self-detonate, hence the invention of the diesel engine, which has the highest fuel efficiency rating), whereas the MON (usually the lesser octane number of the two) is the level of the amount of energy (BTU's) the fuel will provide under an adjustable engine compression ratio at a specific engine speed and load / torque. To achieve the RON number, the engines compression is steadily increased until pre-detonation of the fuel is detectable, so the higher the number, the less likely it is that any particular fuel will pre-detonate in a particular engine at a certain compression ratio. The octane number that a fuel is rated at at the fuel pump, is actually an average between the RON and the MON numbers.
A fuel's relationship to how much energy it will provide is also determined by many other factors, including the engine's compression ratio, the actual temperature of the fuel itself and it's vapourisation level (volatility), the ambient air temperature, altitude and relative humidity, but more importantly is the altitude, at sea level (or a barometric pressure of 1000mB / hPa), the pre-set engine timing is matched to the engine's intended compression ratio, to provide the most effective burn time and rate, but as you climb higher in altitude the compression ratio lower's, and the burn time and rate the fuel will burn will also increase, therefore the less power you will be able to extract from the same octane rated fuel. I know at sea level (1000 mB / hPa) my bike runs a little lean and isn't as responsive and is more prone to knock, whereas at my normal altitude of 640 metres / 2099 feet, it runs a little richer but is heaps more responsive because of the slightly slower burn time of the higher 98 octane and is therefore extracting more energy from the 98 octane than with using 87 octane, that's why I use the higher rated 98 octane fuel.
Lead was a great additive, because it didn't detract anything from the MON octane level but increased the fuels knock resistance (RON), plus providing a cushion for the valve seats and assisted in case hardening the valve seats themselves during the combustion process and helped to lubricate the piston rings and bore.