I just wanted to add that I ran some stat analysis on the amount of powder gained from XP, rings, and souls and the optimal levels mentioned in the first post aren't entirely accurate.
Rings: Level 5 Active Skill is correct. The ring cost per powder goes way up after lvl 5 and is actually higher at lvl 4 than it is at 5 also.
Souls: The sweet spot for soul cost per powder is lvl 14 mercs. The amount of souls spent per powder starts to go up quickly starting at lvl 15. There's also a big jump at lvl 20, so if you have the souls to spend and need more powder lvl 19 is also good - but the price goes way up after that.
XP: The amount of XP needed per lvl goes up steadily as you level up a hero and the amount of powder earned per level also goes up steadily as you level up. However, the amount of XP needed increases faster than the amount of powder you receive. This means that the higher you level up the hero the less powder you gain per XP spent. The amount of XP spent per powder is fairly chaotic from level 1 to around 40, but after that it levels out for the most part with a gradual increase in cost up until level 111 where the price begins to go up rapidly.
To give you an idea of the increase, You earn a total of 533 Magic Powder if you level a hero up to 120. If you break that into 10 chunks of (roughly) 53 powder each you find that for the first 53 powder gained the average cost is 811 XP per powder and for the last 53 powder gained the average cost is 1,294 XP per powder.
However, there are a few sweet spots between level 40 and 110 where the XP spent per powder is far better than at other levels. The 2 most significant spots are level 75 and level 93, with 75 being the better of the 2 in terms of XP spent per powder.
My advice is that if you have a lot of heroes to turn into powder you're better off only leveling them up to 75. However, if you don't have a lot of junk heroes to get rid of then it's worth investing more in each hero, in which case I would level them up to 93 but I wouldn't go any higher than that.
So, in summary, the optimal levels to get the most powder out of your resources are:
Active Skill (Rings): Level 5
Mercs (Souls): Level 14 (best) or 19
Hero (XP): Level 75 (best) or 93