Nothing to do with the "purity" of gasoline - gasoline is a mixture of a large number of different compounds, so purity really doesn't mean much when you are talking about gasoline.
The octane number refers to how much the gasoline can be compressed before it self-ignites. For a normal gasoline engine, the higher the octane number, the higher the compression you can apply before the gasoline ignites before you apply the spark. This pre-ignition is what causes knocking in your car engine - that means the gasoline is actually igniting before the up-stroke of the cylinder is complete, and trying to drive the piston back down before it is ready.
The reason it is called "octane" number is because the standard for comparison is iso-octane (3,3,5-trimethylpentane) which is arbitrarily assigned and octane number of 100. The zero point on the octane rating is heptane. (It turns out that straight chain alkanes tend to ignite when they are compressed, and branched chain alkanes don't - the more branching in general, the higher the octance number). A gasoline mixture is compared to the mixture of octane and heptane required to have the same properties of compression before autoignition.
So the higher the octane number, the higher you can raise the compression ratio on your engine before it starts knocking. High performance engines have higher compression ratios and require higher octane fuel, but as long as your car isn't knocking at whatever octane level you are using, there is no benefit to increasing the octane level.
Diesel engines operate differently - they do not have spark plugs and require a fuel which will autoignite on compression. They use a different scale called the "cetane number", in which 100 is cetane (hexadecane, an unbranched 16-carbon alkane) and 0 is alpha-methyl naphthalene. In general, straight chain alkanes have a higher cetane number than branched chain alkanes.
Back to your original question - the octane number does not indicate the "purity" of the gasoline; it measures the ignition properties of the gasoline.