Figure 1 - A simple electromagnet science project operates in very much the same manner as the dynamo that generates the earth's magnetic field.
It has been generally believed by scientists for the last few decades that solar and planetary magnetic fields are created in much the same way that the magnetic field in a simple toy electromagnet is produced. A current of electricity flows through a wire and creates a magnetic field around the wire (Figure 1).
When the wire is wrapped around a nail, a strong electromagnet can be produced, whose strength changes as you increase or decrease the battery current in the wire. For planets, and some of the moons of Jupiter, magnetic fields are created by currents of charged liquids flowing within the outer core of the body (top right).
Figure 2 - Copyright Calvin J. Hamilton (http://www.solarviews.com/cap/venus/venusint.htm). Planetary magnetic fields are generated by a flow of charged particles often in the deep viscous outer core of the planet.
These currents don't have to look like ordinary electricity that comes out of a battery. Any system of moving charges will work just as well. They can be made of liquid iron-nickel (Earth) or even salt water (Ganymede) which move as the planet rotates. To make the magnetic field strong enough, the current has to flow fast enough and it also has to exhibit some turbulence or convection. If a planet rotates too slowly, the currents do not flow fast enough to produce a strong field. If the interior of the planet is too viscous, or there isn't enough of a temperature difference to produce convection, the field will also not be strong enough. So, when spacecraft fly-by a planet and detect a magnetic field, scientists can also use this information to learn about the deep interior of the planet.
Now let's see how each of the inner planets differs in its magnetism!