Physicists actually have a pretty good idea of how magnets work. Magnetism and electricity are part of the same physical force, electromagnetism, that is also responsible for light.
The theory of electromagnetism was developed in the 19th century and put together by James Clerk Maxwell in the 1860s-70s.
Using the 19th century theory, you can work out just about anything you want to know about electric and magnetic fields, and work out how one kind of field produces the other. One of the few things that you couldn’t work out was why some materials produce a magnetic field. 20th century physics now explains this as well, with the help of what’s called ‘Quantum Mechanics’ and 20th-century knowledge of what atoms are.
The basic ideas behind why materials are magnetic is that
1. Moving electricity produces a magnetic field
2. There is moving electricity in materials because the electrons in the material spin around and go around the centre of atoms.
This is what happens when you ask a biologist a physics question!
My point about not knowing how they work was about quantum theory – I thought that quantum mechanics hadn’t come up with a complete theory on how a magnet works at the atomic and subatomic level. Electromagnetic theory was worked out in the 19th century, yes , mostly by Michael Faraday and James Clerk Maxwell if I recall correctly. But what happens at the atomic level? At what point does the ‘north’ pole become a ‘south pole’ in the magnet?