I found this on a Ford F150 site, it will answer your question in a more accuate way.
The knock sensor just tells the computer when/if it's pinging/detonating. If it is, the computer adjusts the timing to compensate and stop the pinging/detonating. An advancement in timing generally increases your power output but increases the risk of pinging/detonation. Retarding the timing lowers the power output, and decreases the chance of pinging/detonation.
The higher the octane, the less chance of pinging/detonation.
What happens is, the computer reads the knock sensor, and if the engine is pinging/detonating, the computer will know, and back off the timing to make it stop pinging. What the higher octane does, is allow the engine to run a more advanced timing setting before pinging/detonation. The octane gives more breathing room. Therefore, the computer can run a little more of an advance on the timing before it pings/detonates....which is where you get the extra power from.