I'd just like to tack this on with BJ's info.

We light the flame off before top dead center so that the fuel has burnt and made maximum pressure for the longest time possible before the exhaust valve opens. You want to run as much advance as you can without having the engine knock. When you run the hairy edge between knocking and running with lots of power, lots of NOx(smog forming gas) is formed in the process. Auto manufactures know this and have the engine set at a happy medium between running strong and running clean. If you have to pass smog or care what you do to the environment run the number the manufacturer suggests.