Answer :
A magnetic field is produced by movement of electrons. Electrons are charged particles. All magnetic fields are created by charged particles
During an experiment in the early 19th century, it was discovered that when an electric current flowed through a wire , a compass that had been placed nearby would change direction and when the current was turned off, the compass went back to its original North/South alignment with the earth's magnetic field.
The conclusion from this observation was that electrons moving through the wire were creating a magnetic field which was not there when the current was turned off.