The work in picking up something is not done by the magnet, but by you!
Were a magnet and a piece of iron in free space (i.e. vacuum and no gravity), they'd simply start approaching one another, converting the potential energy of the magnetic field into kinetic energy. In gravity field, both would fall downwards, but e.g. if the magnet were above the iron, the magnet would fall slightly faster and the iron slightly slower due to the common attraction.
But now there's you (or e.g. a crane) holding the magnet in a fixed position (and the floor preventing the iron from falling via reactive forces). There are two scenarios:
- You put the magnet on the iron. In that case they simply stick together and when you lift the two, it is obviously you doing the work
- You hover the magnet over the iron. When close enough, the iron will rise to the magnet. But the magnet is also attracted to the iron and pulls downwards. But you won't let it get down, you strain your muscles slightly more in order to counter this. You are doing work when putting the magnetic above the iron, and it is (basically) exactly the amount required to add potential energy to the iron now attached to your magnet.