You can build a very simple electromagnet by coiling a conducting wire and running a current through it. You can make it better by winding the coil around a piece of iron, such as a nail. The reason the nail makes a better electromagnet is because iron conducts magnetic fields thousands of times better than air. The nail allows for a flow of the magnetic field half of the way. If we bend the nail into a circle, the field can now travel through iron almost all of the way. This way, our electromagnet produces a very strong magnetic field that travels through air only at the gap.