let's put some things right
First of all I have to correct papa_smirf that is is not the magnetic forces but the electrostatic forces that need to be overcome to make fusion possible :
Nucleae have a positive electric charge, therefor they repel each other. This is the so called potential barrier that needs to be surpassed, they can do that given sufficient kinetic energy (this means if they have enough speed to smash onto one another) or by quantum tunneling. The last way happens only on very rare occasions since the probability for this to happen is very very low, therefor the only real way is the first. This is for example what happens in the centre of our sun where temperatures are high enough to obtain enough kinetic energy to overcome the barrier.
Where does the energy comes from one the fusion happens ?
Well it is the same kind of energy that comes free when you burn something : exothermal reaction. While in the burning of wood you are dealing with chemical energy and in the 'burning' of atoms you are dealing with nuclear energy. It is called binding energy : in order to make a helium nucleus one takes two neutrons, two protons and puts them together, this resulting in a helium nucleas and its binding energy.
The fusion of nucleae isn't always exothermal once you get to iron atoms you need more energy to make heavier atoms then you get out of the process. This is why stars can burn only so long as they don't start making iron cause that is the end of the line. This is also why elements heavier then iron aren't that abundant in nature : it is very hard to make them (it takes a supernova actually).
The above picture gives some insight, I hope.
The pit actually represents lower energy states where protons and neutrons can reside in if they are close enough together. The energy difference between their energy in their free states and in their bound states represent the binding energy that comes free.
However since neutrons and protons are fermions, no two particles can be in the same quantum state. In other words as one piles protons and neutrons into the pit, it becomes full. Before you know it, it becomes harder to put anything more behind the potential barrier since all the states below your ground state are filled. If you still want to pile things on top, it will cost you more energy !
Very heavy nucleae are almost overloaded with particles and tend to lose a few now and then, this is called radioactive decay.
About the magnetic field of the moon and the earth :
There is a very big difference between the two : first of all the moon has no full covering magnetic field as the earth has. In fact it is a far stretch to talk a bout a magnetic field for the moon at all since it is a combination of several magnetic fields stemming from patches of moon rock that are magnetised. This however is very close to the surface and would for example not serve at all to hold a compas at a magnetic north pole. The field of the moon is static and will never change only diminish over time. So there is no way that it can switch poles.
The field of the earth however finds its origin in the semi liquid core, there electical currents are sustained in semi steady paths thus maintaining a magnetic field spanning the entire planet with two distinct poles. The paths that the currents follow change over time due to the earths rotation and the not so homogeneous constitution of its core. This results in a depolarisation over time and ultimately a switch of poles.