How do magnets work?
A magnet is any object that has a magnetic field. It attracts ferrous objects like pieces of iron, steel, nickel and cobalt. In the early days, the Greeks observed that the naturally occurring 'lodestone' attracted iron pieces. From that day onwards began the journey into the discovery of magnets.
These days magnets are made artificially in various shapes and sizes depending on their use. One of the most common magnets - the bar magnet - is a long, rectangular bar of uniform cross-section that attracts pieces of ferrous objects. The magnetic compass needle is also commonly used. The compass needle is a tiny magnet which is free to move horizontally on a pivot. One end of the compass needle points in the North direction and the other end points in the South direction. The end that points in the North is called the North Pole of the magnet and the end that points South is called the South Pole of the magnet. It has been proven by experiments that like magnetic poles repel each other whereas unlike poles attract each other. The space surrounding a magnet, in which magnetic force is exerted, is called a magnetic field. If a bar magnet is placed in such a field, it will experience magnetic forces. However, the field will continue to exist even if the magnet is removed. The direction of magnetic field at a point is the direction of the resultant force acting on a hypothetical North Pole placed at that point. When current flows in a wire, a magnetic field is created around the wire. From this it has been inferred that magnetic fields are produced by the motion of electrical charges. A magnetic field of a bar magnet thus results from the motion of negatively charged electrons in the magnet. This is how a magnet works. - foofoo