The gradient of the magnetic field produced by the magnet is what causes magnetized and magnetizeable objects to be attracted to the magnet.
The force felt by the material due to a magnet or an applied magnetic field is given.
where m is the magnetization of the material and B is the magnetic field. If the material in question is uniformly magnetized, this can be reduced to. If there is a uniform magnetic field (no gradient) then there is no attraction, but there is always a gradient somewhere. The magnetic field gradient from a bar magnet can be visualized with iron filings.
The pattern produced by the iron filings has a lower density further away from the poles of the magnet and a higher density closer to the poles of the magnet, reflecting a gradient in the density of field lines.
To feel a force from this magnetic field gradient, a material needs to be magnetic , and there are three possibilities for how a material will magnetize in response to an applied magnetic field (for this question, the permanent magnet provides the magnetic field).
Diamagnetic materials get magnetized opposite to an applied magnetic field, and they would be repelled by a bar magnet. A superconductor is a very good diamagnet, but many conventional materials, including water and graphite, are also diamagnetic. Among the elements, those without unpaired electrons, such as the noble gases, Zn, and Si are slightly diamagnetic. Among compounds, those with de-localized pi-electrons (and no unpaired electrons) tend to be diamagnetic. Below is a photo of graphite levitating above bar magnets.
Paramagnetic materials have unpaired electrons but are not permanent magnets. A magnetic field compels some of the electron spins to point in the same direction as the applied field, but this induced magnetization is usually not enough to make a paramagnet be attracted noticeably to a bar magnet. Sodium and Aluminum are examples of paramagnetic elements.
Ferromagnetic materials are permanent magnets, of which Cobalt, Nickel, and (especially) Iron are key examples. These materials can have all of the electron spins pointing in the same direction over macroscopic length scales without an applied magnetic field, and it is these sorts of materials which both constitute permanent magnets are are attracted to permanent magnets.
Most ferromagnetic materials consist of small magnetic domains where all of the electron spins point in the same direction. Domains are usually oriented in different directions so a ferromagnet will usually not have an overall magnetization. However, when a ferromagnet gets close to a permanent magnet, those domains which are aligned with the magnetic field of the permanent magnet become more energetically favorable and they grow at the expense of other domains. This is sketched in the image below. Thus, the material gains a net magnetization from the magnetic field of the magnet and feels an attractive force from the gradient of field of the magnet.
The boundaries separating magnetic domains in a ferromagnet are called domain walls, and the growth of the favorably-aligned domain in the presence of a magnetic field can be viewed in terms of domain wall motion. Impurities and defects can 'pin' domain walls such that a ferromagnetic material does notgain a net magnetization in the presence of a (weak) permanent magnet. This is the reason why your stainless steel tableware and cutlery (stainless steel=Iron+carbon+chromiu
One final note: the phenomenon of ferromagnetism is an example of quantum mechanics at very high temperatures. If the interactions between electron spins is considered in a semi-classical way as magnetic dipole interactions (i.e. two bar magnets next to each other), first of all, they will want to point in the opposite direction as their neighbor, and secondly, magnetic order will only happen at ~1K. But iron is ferromagnetic up to 1000K! The origin of ferromagnetism in in your refrigerator magnets is a quantum mechanical interaction called Exchange interaction, based on the Pauli exclusion principle. But this is a topic for another question.
Complicated answer, but here is the short version...The only metals that are magnetic at room temperature (superconductors must be very cold) are Iron, Nickle and Cobalt; ferromagnetic materials. Most atoms on the periodic table pair up and their electron spins cancel each other out hence non-magnetic. The three magnetic metals have a excess of unpaired electrons that want to align their magnetic dipoles with an external field. Any ferromagnetic material can also be a magnet in the common sense (think refrigerator magnet) by exposing it to a strong magnetic field that forces the unpaired electrons to all "point" in the same direction creating a coherent field. Normal Iron, for instance, has many unpaired electron "domains" with dipoles pointing in random directions so it is not normally magnetic until all electrons are aligned into unified n/s domains by a strong magnetic field.