Electromagnets are simple devices that mimic the behavior of natural magnets, with one important difference: the ability to change their magnetic field strength because of their electrically generated magnetic fields. Varying any of the four basic elements of an electromagnet allows you to set the field strength as needed.
TL;DR (Too Long; Didn't Read)
The four main factors that affect the strength of an electromagnet are the loop count, the current, the wire size, and the presence of an iron core.
Number of Loops
An electromagnet is made out of a coil of wire wrapped around a metal core -- usually iron -- and connected to a battery. As the electrical current moves around the loops of the coil, it generates a magnetic field like that of a small bar magnet. It has a north pole on one side of the loop and a south pole on the other. Because the coil is made out of one continuous wire, the magnetic fields of each loop “stack up,” creating something like a large bar magnet. One way to increase or decrease the strength of the magnetic field is to change the number of loops in the coil. The more loops you add, the stronger the field will become. The more loops you remove, the weaker the field will become.
The Metal Core
The metal inside the coil magnifies the field created by it. Changing the metal core for a different metal will make the electromagnet stronger or weaker. Iron cores make for very strong fields. Steel cores make weaker fields. Neodymium cores make the strongest fields. Sliding the core partially out of the coil will weaken the field, because less of the metal is within it.
Sciencing Video Vault
Changing the amount of current flowing through the electromagnet will also change the field the it produces. The greater the current in the coil, the stronger the magnetic field will grow. Conversely, lowering the battery voltage decreases the current, weakening the field. This fact has a complication, however: when you increase the current, the magnet wires get hotter, and possibly fry the delicate electrical insulation without which the magnet can't work.
Although metal wires are very efficient conductors of electricity, they still have some resistance to the flow of current. Using larger gauges of wire on the coil will decrease this innate resistance. This will increase the current and therefore the field. Using smaller gauges will increase the resistance, reduce the current and weaken the field. Using different types of metal wire will also affect the field strength, because every metal has a different inherent resistance to current.