Because magnetic fields were not discovered until recently, the history of how they were discovered is quite interesting, and informative.
The Detection of Magnetic Fields
We begin by giving an empirical history of the development of electromagnetic theory. As stated, people had long known that magnetic fields existed, but the only known source of these fields were permanent magnets, and no link was made to electricity. In the early 1800's, Hans Christian Oersted began to make the connection between electricity and magnetism. Oersted did most of his work using compass needles, but we will derive the existence of magnetic fields, and their relation to electricity, using more familiar systems-current carrying wires.
Consider two current carrying wires running parallel to one another. A current is simply a collection of moving charges. Traditional electric theory predicts that, since the net charge on each wire is zero, there is no interaction between the two wires. Experiments in the 1800's, however, showed a surprising result: the wires were actually attracted to each other! The experiment was repeated, with the currents running in opposite directions, with the result that the wires were mutually repelled. Both situations are depicted below.
This experiment established that there was some sort of connection between magnetism and electricity, but a few more distinctions had to be made to generate a coherent definition. Firstly, if a metal sheet (a conductor) were placed between the two wires, it had no effect on the phenomenon. Since conductors shield electric forces, clearly this phenomenon was not the result of some unknown electrical interaction. Secondly, if a static charge (i.e. a charged particle that does not move) were to replace one of the wires, the charge itself would feel no forces.
From these empirical observations we can develop a qualitative understanding of magnetic forces and fields. Let us assume first that the observed phenomenon is in fact the result of a magnetic field. Where does the field come from? Well, since the only objects in the experiment are wires, we can make the following statement linking electricity and magnetism:
Magnetic fields are caused by moving charges.
From further experiments, scientist determined that any charged particle with a velocity causes a magnetic field. The second question that must be asked about magnetic fields is on what objects do they act? The observation that a nonmoving charge is not affected leads us to our second statement about magnetic fields:
Magnetic fields only act on moving charges
From these two statements, we may think of electricity and magnetism in the following way. Electricity is the study of the interaction between static charges. Magnetism is the study of the interaction between moving charges. Both result from the existence of electric charge, and can simply be seen as different topics in the study of electric charge. It goes without saying that the two are interrelated.