Your Compression Ratio dictates the Octane Rating of the gasoline that your engine requires. The Octane Rating tells you how much the fuel can be compressed before it spontaneously ignites, otherwise known as Detonation.
A high performance engine with a 11:1 high compression ratio requires slower burning compression resistant fuel of higher octane. A stock engine with a 8:1 lower compression ratio can efficiently use a faster burning less compression resistant lower octane fuel which saves money.
In other words, 87 Octane gasoline is gasoline that contains 87-percent octane and 13-percent heptane (or some other combination of fuels has the same performance of the 87/13 combination of octane/heptane). It spontaneously ignites at a given compression level, and can only be used in engines that do not exceed that compression ratio.
Knocking or pinging generally requires adjustment of the ignition timing and/or the use of a higher octane fuel. The ignition timing due to the speed of which the gasoline burns and the octane rating due to it's compression resiliency.
As a side note, some time ago refineries found that they could add tetraethyl lead (TEL) to cheaper grades of gasoline to enhance it's octane rating. Hence, "ethyl" or "leaded" gas. After lead gasoline was generally banned due to environmental hazards, refineries were forced to use higher grades of gasoline at more expense. 100 octane leaded Aviation AvGas is still available for aircraft.
Stock compression for a 302 is 9:1. Stock compression for a 351W is even less at 8.8:1.
BTW, a non-working or removed EGR can also cause Detonation as well. A working EGR reinserts small amounts of exhaust into the intake manifold that, although hot, still has a cooling effect on combustion temperatures by diluting the air/fuel mixture slightly. When the cooling effect is lost, it creates higher combustion temperatures under load and an increased chance of detonation. Believe it or not.