During early 600BC, the Greeks discovered a new type of iron ore called lodestone that could attract other pieces of iron, this was later known as magnetism. When allowed to rotate freely, lodestone would rest in a north-south position. Due to this lodestone was mainly used for navigation, however nowadays lodestone is rarely used for navigation, iron, nickel and cobalt are more used for artificial magnets.
Substances that become magnetized or unmagnetized instantly are called soft ferromagnetic materials. There are also hard ferromagnetic materials and they are when iron alloy with materials such as aluminum and silicon, the result is that iron maintains its magnetic abilities and are used to create magnets.
When looking at the atoms of ferromagnetic substances they can be described as having microscopic magnets with north and south poles. They interact with other dipoles to create a magnetic domain. Unmagnetized irons have many of these domains but they point in random directions so the iron itself isn't magnetized (as shown in the image below).
When an unmagnetized piece of iron is placed in a magnetic field the dipoles react by rotating until they are aligned with the field, thus creating a north and south pole (as shown in the image above).
Magnets can also make other objects become magnets temporarily, for example if you put a magnet on top of a nail, the nail becomes a magnet temporarily. This is because the field of the magnet causes the dipoles in the nail to align making it a temporary magnet. The duration of which the nail is a magnet depends on the material for example a steel nail dipoles tends to retain their alignment for longer periods of time than an iron nail.
When we look at two magnets together we can see that north poles repel each other and the south poles repel each other as well, but north and south poles attract each other, this is also known as law of magnetic poles.
Before north and south poles touch each other they attract this is because of the magnetic field around them. A magnetic field is a three dimensional object around a magnet that exert forces on other magnetic objects. Magnetic field lines point from north to south on the outside and south to north on the inside, and they cross one another.
Applications of magnetic fields can be AC and DC electric motors, to make a tight seal in refrigerators and freezers, Maglev trains use magnets for levitation and forward motion.