What is a magnetic field? How were they formed?
I am not sure that my answer will satisfy you but...
A magnetic field is a region of space where, in every point, is present a magnetic force odf the type:
Here you can see a similarity with Electric Field where you have:
The difference is that the first has the velocity term in it!
We can resume all saying that:
A charge produces around itself an Electric Field
We can summarize mathematically by writing (for a charge
If the charge is at rest it is ok you get only a E field...if it also moves we add the Magnetic one!
Basically, every time you have a moving charge you have the formation of a magnetic field; for example:
1) around a wire carrying electricity;
2) in a magnetic material; this time caused by the electrons "moving" around in the atoms;
3) in and around a solenoid carrying a current (as in a transformer).
Hope it helps!