Iran's biggest problem was not lack of human or natural resources--Iran exceeded Pakistan far better on both of those counts. Iran relied on the proxies as Iran's 'nukes', and Iran had no major powerful neighbor ready to attack and grab land unlike Pakistan has faced for 80 years. So Pakistan has evolved to be a powerful, ever vigilant 'security state' unlike Iran.
And Iran ventured into the territory of challenging a Super Power's progeny/master...
Having said that, I hope Iran comes out ahead from this conflict and I think they can if they fight as one nation and be willing to pay whatever price it takes; otherwise, the alternate is another Syria or Libya or Iraq (yes, even Iraq).