In the presence of an external magnetic field(bringing a magnet close to a metal), the atomic magnetic moments are forced to align along a particular direction, either along the direction of the field or opposite to the direction of the field. This realignment is in accordance with Lenz's law.
When the moments align along the direction of the field, there's an attractive force that sets in and thus the metal is attracted to the magnet.