Why do physicists say that a magnet can’t do work? They don’t!!!
What they do say is that a magnetic field does no work on a classical spinless point particle (and that a homogeneous magnetic field does no work on a particle with spin either). But this in no way precludes the field of a magnetic dipole doing work on another object with a magnetic moment – as we observe every day in electric motors, and when we see the attraction of oppositely oriented bar magnets (and the lifting of anything from iron filings to scrap ferromagnetic metal by virtue of the magnetization induced in them by a strong magnetic field).
The question of where the energy to do this work comes from is probably most simply answered by saying that it was put into the magnet by the work necessary to get its atomic spins into alignment, and then resides in the external magnetic field (which, when the magnet has done work, gets reduced or cancelled out by the opposite fields from the objects which have been attracted – but can be restored by pulling them apart again). What is completely wrong is the claim made in some answers (including the one with the highest number of upvotes!) that the source of energy has anything to do with the process of moving the magnet and holding it above the items it is lifting.
Of course, since magnetic fields (like all the other force fields we are familiar with) are conservative, there is no net work done in a cyclical process unless we have an external source of energy (like an electric current supply). But this is true of all physical systems and not any special property of magnets.