Magnetic energy is the energy within a magnetic field. This energy results in various metals either repelling or attracting each other.
Magnetism and electricity are closely related but, prior to the 19th century, scientists did not know this. This discovery is thanks to James Clerk Maxwell, a Scottish physicist. His proposal involves the fact that there is a magnetic field for every electrical current, and that all magnetic currents create an electrical current. His equations, or Maxwell's Equations, form the base for magnetic energy and electrical energy and almost all research after their creation is due to his work in this field.