You want to run the lowest octane you can get away with, without causing detonation (pinging).
You'll get better gas mileage and more HP with the lowest octane possible.
Octane is simply a measurement of the temperature the fuel can resist before igniting, basically. So, having just enough octane to not pre-ignite gives you a more complete burn and results in extra power and fuel economy.
Having a higher octane would allow you to say, use higher timing and then gain extra power that way but stock ECU's are usually too conservative for this.
Being at a higher altitude lets you run lower then normal octane.. ie. if the manufacturer recommends "premium" -- that may be 93 at sea level, but at high altitude (3000+ ft. elevation) that means 91 octane. The air is less dense at altitude, and thus you can get away with lower octane without pinging.
Colder air results in more power for the same reason.. colder air is more dense.
Moral of the story... use the recommended fuel unless you really know your car/engine and the signs to look for/listen for as far as pinging goes... a bit of saved pennies/fuel does not replace an entire engine
