A magnet basicaly attracts a ferromagnetic materials. Ferromagnetic materials are those materials that can be magnetized and can become a magnet, such as, iron. Magnet attracts these specific materials through magnetic field. Actually, a Magnet produces it's own magnetic field and also responds to it. When a electric charges, such as electrons move it produces a magnetic field like a small magnet. The movement (or rotation) of the electrons on it's axis (known as spin) and around nucleus in atoms is the main source of ferromagnetism.

Usually electrons prefer to pair up with another electron with the magnet pointing the other way - so the pair of electrons together has no magnetic dipole, they effectively neutralize each other. In many atoms you have only such pairs of electrons, so the whole atom has no magnetic dipole. But if there are an odd number of electrons, such as Alumnium (having 13 electrons), there is at least one 'unpaired' electron, at the whole atom will have the magnetic dipole of this one electron; the whole atom will act as a bar magnet and respond to external magnetic fields.

The billions of atoms in the iron and other metals are packed in a scattered way, but when they enters a magnetic field, more and more of its positive atom poles point in one direction, toward the negative pole of the big magnet, and more and more of its negative atom poles point the other way, to the big magnet's positive pole. Since these opposite poles attract each other, these metals jumps and cling to the magnet.

The largest magnet in the world is the earth itself, because the hot nickel and iron at its core pull everything towards it!