Why can electricity make a magnet?

Milo experiment guide: build an electromagnet with wire, nail, and battery