Lets break it down to basics.

Backfire - out of the exhaust - Bang, Bang or Pop, Pop, Pop.

For this to happen, unburned fuel has to get through the engine into the exhaust system in sufficient quantity to be able to ignite. It also has to have enough oxygen for combustion. There has to be a an ignition source.

When the engine is fully warm, you can produce a backfire by turning off the ignition for a couple of seconds (at speed, down hill works best) and switching it back on. Should give a good bang. Run it off too long and you could blow the muffler off.

How to have it do it on it's own:

Loose primary wire that cuts the ignition on and off.
Sticky set of points that fire randomly.
Sticky exhaust valve that hangs open.
A rich mixture and an air leak in the exhaust ahead of or in the muffler.

That is a start.