Headers are one of the easiest bolt-on accessories you can use to improve an engine's performance. The goal of headers is to make it easier for the engine to push exhaust gases out of the cylinders.
When you look at the four-stroke cycle in How Car Engines Work, you can see that the engine produces all of its power during the power stroke. The gasoline in the cylinder burns and expands during this stroke, generating power. The other three strokes are necessary evils required to make the power stroke possible. If these three strokes consume power, they are a drain on the engine.