At the start of my electricity and magnetism course, I usually emphasize that although the electrostatic and magnetic forces are of the same family of forces, they must not be confused as the same thing. The average person interacts with both of these forces daily and has little understanding of either. It takes a while to wrap one's head around magnetism, but let's give it a try...
The mere presence of a charge creates an electric field, which can exert an electrostatic force upon another charge. This is the basis of electrostatics. In order for a magnetic field to be produced, charge must be in motion. It then follows that for a charge to experience a magnetic force within a magnetic field, it too must be in motion. This is the basis of magnetism. So, whereas all charges produce and respond to electric fields, only those in motion produce and respond to magnetic ones.
The electrostatic force acting on a charged particle in an electric field is quite straight forward:
Here, charge q, which moves with velocity v, responds to magnetic field B. Those familiar with the cross product will note that the magnetic force acts neither along the axis of v nor that of B. Actually, v and B form a plane, and the magnetic force acts on the particle perpendicular to this plane. This may seem bizarre, but if you would like to design a better universe than this one, I challenge you to try.
Reflecting further, we see that the only way that a charged particle can be moving within a magnetic field and not experience a magnetic force is if it travels parallel to it. The more orthogonal the motion, the greater the magnitude of force.
We can finally combine these ideas and describe the electromagnetic force that acts on a charged particle within an electromagnetic field (both electric and magnetic fields are present):
Focusing again on just magnetism, you may be wondering how permanent magnets, like those that stick on refrigerators, work. The above suggests that charge must be moving in order to act as magnets. For this, we need to look closer. At the atomic level, charge is constantly in motion. However, just as neutral atoms exert no net electric field, the typical symmetry of orbiting electrons tends to produce no net magnetic field. It is only with certain atoms that the electron orbiting is asymmetric, leading to a net magnetic field. Iron is the best example of this. For this reason, the scientific term to describe a permanent magnet is 'ferromagnetic'.
There is a net asymmetry of motion of charge within many planets, and this is why they often behave like giant permanent magnets, with two magnetic poles.
Where else is charge moving in an orderly fashion? Wherever there is a current. And, if a current-carrying wire is placed within a magnetic field, a force will act on it. This force, some distance from an axis of spin can lead to a torque, and this is the basis of electric motors - one of the more significant inventions of the nineteenth century.
So, when the five-year old, having completed his or her experimenting with the magnets asks, "How do these work?" you may just want to say, "Magic." The truth is very complicated, and, as Arthur C. Clarke put it so eloquently, "Any sufficiently advanced technology is indistinguishable from magic".
I have found that learning about the code that our universe appears to follow does not make it seem less magical. My awe for the unknown reason why two magnets should pull on one another is replaced by the awe that my little brain can understand how they do it.