The higher octane is required in higher altitudes. 87 at sea level will give more power than 91 in Denver (caveats apply)
The main caveat being: That first statement is completely incorrect. As altitude increases, ambient pressure decreases. As ambient pressure goes down, max pressure developed in the cylinder decreases as well. As max pressure decreases, the tenancy for pre-ignition (knocking) decreases. As the tenancy for pre-ignition decreases, octane requirements are lessened.
In other words, all things being equal, higher octane is required in lower altitudes.
(But you are right in your second assertion - assuming your engine will run on 87 octane at sea level, it will indeed make more power at sea level than it will in Denver - mainly because of the increased air density at sea level.)