Magnetic energy is the potential energy due to or stored in magnetic fields. Magnetic energy and electric energy are related to Maxwell’s equations. In fact, thanks to Maxwell’s work, magnetic and electric energy are more appropriately considered as a single force. Together, they are what is known as electromagnetic energy (a form of energy that has both electrical and magnetic components).
It is created when one runs a magnetic current through a wire or any other conductive material, creating a magnetic field. The magnetic energy generated can be used to attract other metal parts (as in the case in many modern machines that have moving parts) or can be used to generate electricity and store power (hydroelectric dams and batteries).