The compression ratio is pretty much what it sounds like--how much the motor compresses the air/fuel mixture before it burns it up (by igniting it with the spark plug). The thing is, the more you compress an air/fuel mixture the more it's going to want to explode without adding a spark to it. When this happens it's called detonation, knock, ping, etc. They're all the same thing. This is bad and can mess up your motor. Higher octane gas has a higher resistance to detonation, which is why you need the higher octane gas in a car that runs a higher compression ratio. This is obviously only one factor though and there's tons of other things which determine what octane your car needs.