As with all great discoveries the history of magnets is very colorful and interesting too.
The Shepherd Magnes
The most popular legend accounting for the discovery of magnets is that of an elderly Cretan shepherd named Magnes. Legend has it that Magnes was herding his sheep in an area of Northern Greece called Magnesia, about 4,000 years ago. Suddenly both, the nails in his shoes and the metal tip of his staff became firmly stuck to the large, black rock on which he was standing. To find the source of attraction he dug up the Earth to find lodestones (load = lead or attract). Lodestones contain magnetite, a natural magnetic material Fe3O4. This type of rock was subsequently named magnetite, after either Magnesia or Magnes himself.
The Greek & Chinese
The earliest discovery of the properties of lodestone was either by the Greeks or Chinese. Stories of magnetism date back to the first century B.C in the writings of Lucretius and Pliny the Elder (23-79 AD Roman). Pliny wrote of a hill near the river Indus that was made entirely of a stone that attracted iron. He mentioned the magical powers of magnetite in his writings. For many years following its discovery, magnetite was surrounded in superstition and was considered to possess magical powers, such as the ability to heal the sick, frighten away evil spirits and attract and dissolve ships made of iron!
People believed that there were whole islands of a magnetic nature that could attract ships by virtue of the iron nails used in their construction. Ships that thus disappeared at sea were believed to have been mysteriously pulled by these islands. Archimedes is purported to have used loadstones to remove nails from enemy ships thus sinking them.
People soon realized that magnetite not only attracted objects made of iron, but when made into the shape of a needle and floated on water, magnetite always pointed in a north-south direction creating a primitive compass. This led to an alternative name for magnetite, that of lodestone or "leading stone".
For many years following the discovery of lodestone magnetism was just a curious natural phenomenon. The Chinese developed the mariner's compass some 4500 years ago. The earliest mariner's compass comprised a splinter of loadstone carefully floated on the surface tension of water.
Peregrinus & Gilbert Peter Peregrinus is credited with the first attempt to separate fact from superstition in 1269. Peregrinus wrote a letter describing everything that was known, at that time, about magnetite. It is said that he did this while standing guard outside the walls of Lucera which was under siege. While people were starving to death inside the walls, Peter Peregrinus was outside writing one of the first 'scientific' reports and one that was to have a vast impact on the world.
However, significant progress was made only with the experiments of William Gilbert in 1600 in the understanding of magnetism. It was Gilbert who first realized that the Earth was a giant magnet and that magnets could be made by beating wrought iron. He also discovered that heating resulted in the loss of induced magnetism.
Oersted & Maxwell
In 1820 Hans Christian Oersted (1777-1851 Danish) demonstrated that magnetism was related to electricity by bringing a wire carrying an electric current close to a magnetic compass which caused a deflection of the compass needle. It is now known that whenever current flows there will be an associated magnetic field in the surrounding space, or more generally that the movement of any charged particle will produce a magnetic field.
Eventually it was James Clerk Maxwell (1831-1879 Scottish) who established beyond doubt the inter-relationships between electricity and magnetism and promulgated a series of deceptively simple equations that are the basis of electromagnetic theory today. What is more remarkable is that Maxwell developed his ideas in 1862 more than thirty years before J. Thomson discovered the electron in 1897, the particle that is so fundamental to the current understanding of both electricity and magnetism.
The term magnetism was thus coined to explain the phenomenon whereby lodestones attracted iron. Today, after hundreds of years of research we not only know the attractive and repulsive nature of magnets, but also understand MIR scans in the field of medicine, computers chips, television and telephones in electronics and even that certain birds, butterflies and other insects have a magnetic sense of direction.