The ATX standard has two different versions of the main power cable: the original 20 pin cable, and the newer 24 pin cable. The 24 pin cable is just the 20 pin cable with 4 extra wires added to the end to provide extra current. If your power supply main power cable and motherboard main power connector both have the same number of pins then they'll (of course) fit together just fine. But what happens if they don't match? If you plug a 24 pin power cable into a 20 pin motherboard then it will work fine but you often can't get them to physically fit together because something gets in the way. If they don't fit together then you can get an adapter cable which converts a 24 pin power cable into a 20 pin cable. You can always plug a 20 pin power cable into a 24 pin motherboard but whether it works over the long haul depends on how much current your motherboard draws. Those extra 4 pins provide more current carrying capacity. Plugging a 20 pin cable into a 24 pin motherboard can strain the 20 pins that you're using. If the motherboard draws too much current then it will overheat the connector which can burn or melt it. There are adapters which convert 20 pin cables into 24 pin cables but they don't solve the problem and can cause problems of their own. Many newer power supplies come with a 20+4(last 4 pins is detachabel)power cable which has a 24 pin connector which can be split into two pieces: a 20 pin piece, and a 4 pin piece. This kind of power cable is fully compatible with both 20 and 24 pin motherboards. If you're buying a new power supply then try to get one with a 20+4 power cable.
The 24 pin power supply was created to address additional current requirement on newer motherboards, these 4 pins are supplied with the following voltages; +3.3V,+5V,+12V and Ground.It is also use to power-up the PCIe slot of newer motherboards, pcie cards may not function if you are only using a 20 pin power supply.
Picture courtesy of motherboard.org