Here's a simple way of thinking about a few things...gasoline is a mixture of hydrocarbons from mainly C5-C8 chains, that means that for every "one" of those carbon chains you get 5-8 times as much CO2 (and about the same H2O vapour) produced on combustion. 1 (mole) of the hydrocarbon liquid (gasoline) occupies about 100ml (ish) and on combustion this 100ml turns into 5-8 X 22.4 L CO2 and 6-9 times 22.4 L of H2O vapour, the gasses that expand and push the pistons around.
Ethanol when it burns turns into 2 lots of CO2 and about 3 lots of H2O vapour...ie less gas volume. Produces less work but because the combustion products are the same it can be used in fuel. A bit like cutting heroin if you like.
These chained hydrocarbons aren't just found in straight chains, sometimes they have carbon branches on the chains, these are generally better in terms of igniting properly in the engine. One of them is 2,2,4-trimethylpentane which means that it is a C5 hydrocarbon with 2 single C groups on the second carbon of the main chain and one on the 4th carbon of the main chain. The octane rating you see basically refers to the characterisitics of a fuel containing a certain percentage of this compound. So 94 octane gas has the same characteristics as a mixture of 94% 2,2,4-trimethylpentane (it doesn't mean that it actually contains this much, just that it has the same properties as a mixture of that much of the pentane derivative and 6% heptane, a C7 straight chain hydrocarbon).
When you branch a hydrocarbon you increase the boiling point and combustion point (generally more carbons = higher boiling point/combustion point and higher surface area, such as with branched hydrocarbons, = higher boiling point and combustion point). More branched hydrocarbon in the mixture = higher combustion point (higher temp at which fuel ignites). Higher combustion point = less tendancy to knock or ignite at the wrong point in the combustion cycle. Higher octane fuels are thus igniting at higher temps and if your engine isn't designed for this then over time things may obviously wear a lot quicker.
Edit: Apologies for this..I was bored and I finished marking a class today. Really need to switch off.