I know where the muscular energy required to lift the iron comes from. But where did the energy required to lift the iron by the magnet come from?
Just like a gravitational system has gravitational potential energy (that can be released by allowing an object to fall within it), a magnetic system has magnetic potential energy.
In your scenario 2, the magnetic potential energy is lower after the iron has lifted onto the magnet. The lifting process has reduced the magnetic potential energy and increased the gravitational potential energy. The reverse happens if the iron is moved from the magnet to the desk.
Here's another way to think about it. Instead of a magnet, imagine you have a very dense piece of matter that is held above your desk. It's gravitational pull can lift the book so that instead of sitting on the desk, it "sits" on the object.
The energy to do this lift comes from the fact that the potential energy of the book being near this object is lower than the book being near your desk.
How is the magnet resupplied with energy so that it can continue to lift the iron?
Once lifted, no energy is required to keep the object in place, any more than a shelf requires energy to hold a book up against gravity. To remove the object requires increasing the magnetic potential energy. This energy is supplied by whatever force pulls the iron away (such as your arm).