The issues involving Iran are quite exceptional, focusing primarily on these issues gives a rather misleading picture about the NPT. So, let's start with considering what the whole point of the NPT is.
When nuclear technology was developed after WWII, it was clear that the vast majority of the countries in the World would not be able to develop this technology on their own, which would mean that they would not be able to enjoy the benefits of nuclear energy unless they would be given access to it by the few countries that had developed it. Note that at that time, the public image of nuclear image was different from what it is now, it was seen as a miracle energy source, with only a small amount of enriched uranium needed to power a giant 1000 megawatt plant.
There was one big obstacle standing in the way of realizing this nuclear utopia, and that was that the same technology could be used to produce nuclear weapons. The NPT treaty is a solution to this specific problem, it imposes restrictions on how a country can use the acquired nuclear technology. It imposes an inspections regime and transparency rules to verify that a country is sticking to the rules. These transparency rules mean that the member state cannot pursue any nuclear weapons related activities.
However, at heart, the NPT is not a restrictive treat that can prevent countries from produce nuclear weapons on their own. One can see that most clearly from article ten of the NPT that allows countries to leave the NPT after giving a 3 months notice. So, signing the NPT is not an irreversible act that would irreversibly revoke a countries sovereign right to develop nuclear weapons, it's just that a country is barred from using whatever it gets by virtue of being part from the NPT, to pursue a weapons program.
But for transparency purposes, this means that the country cannot pursue a nuclear weapons program as long as it is part of the NPT even if it were able to keep weapons related activities separate from what it would get from its NPT membership. In case of India, a special arrangement was made to allow the US to sell civilian nuclear technology to India. In this case India had to implement certain measures to keep its weapons related activities separate from its civilian infrastructure.
Since in practice, the only realistic way things could spiral out of control leading to a World where we would have wars breaking out fought with nuclear weapons, would be due nuclear technology spreading, and not due to countries developing nuclear technology on their own. Therefore the NPT is a very important treaty to make sure this does not happen and to get to nuclear disarmament. To achieve the latter aim, the NPT asks the declared nuclear power to engage in negotiations to reduce their nuclear stockpiles. The treaty has been updated several times to make it stronger, e.g. the Additional Protocol has been added to strengthen the transparency about nuclear activities of member states.
Now, as I mentioned at the start, Iran's case is exceptional, it has little to do with how the NPT is supposed to work. It's a good example of how it is not supposed to work and how things can spiral out of control due to distrust. Basically the problem started back in the 1980s when the US was worried that Iran's access to nuclear technology via the NPT could be abused for a weapons program even if Iran were never to violate any rules. So, the scenario that the US feared was that Iran simply sticks to all the rules, Iranian scientists and engineers get familiar with nuclear technology and then Iran can later decide to leave the NPT by invoking Article ten during some conflict. Obviously the Iran-Iraq war going on at that time was such a conflict that led to the suspicions that Iran would likely be motivated to pursue nuclear weapons.
This thinking led to the US to impose diplomatic pressure on countries involved in Iran's nuclear program, leading to delays in the construction of the Bushehr nuclear powerplant:
According to Moscow Defense Brief, until 2005 Washington exerted considerable diplomatic pressure on Russia to stop the project, as the US administrations viewed it as evidence of Russia's indirect support for the alleged Iranian nuclear arms program. The United States also tried to persuade other countries to ban their companies from taking part. For example, Ukraine's Turboatom was to supply a turbine, but cancelled the deal after the US Secretary of State Madeleine Albright's visit to Kiev on 6 March 1998. The United States lifted its opposition to the project in 2005, partly due to the deal signed by Moscow and Tehran, under which spent fuel from the plant would be sent back to Russia.
This attitude likely led to Iran to make the decision to pursue an enrichment program in the late 1990s. Obviously if you can hardly get access to nuclear technology to get the Bushehr reactor finished, getting fuel for it would probably be impossible. And in the 1990s, Iran could not know that in the 2000s Putin would be Russia's leader who would steer Russia a bit clear from Western pressure. For all Iran could know in the 1990s, Russia was well on its way to become more integrated with the West, so it would likely become more under pressure from the US to stop being involved in its nuclear program.
Now, the way Iran decided to get the nuclear technology needed for enrichment violated some aspects of the transparency rules, but there were no breaches of the safeguard agreements. Inspections performed later by the IAEA never found evidence of activities related to a weapons program. Also Iran did not violate any rules for having build the Natanz enrichment facility and not a priori notified the IAEA about it, as under the rules, Iran was only supposed to notify the IAEA 6 month's before it would become operational.
But, obviously, the US plan to prevent Iran from operating any large nuclear powerplants lay in tatters after it was found out that Iran had constructed an enrichment facility. Also it was fuel to the US' original suspicion that Iran's access to nuclear technology was actually a problem regardless of whether or not this was done by "by the book". Rather than recognize that its efforts to restrict Iran from having access to nuclear technology had backfired, the US wanted to impose new restrictions. But the only way forward was to get international support for the US position.
This was the start of a decade long back and forth fight involving Iran's rights and international obligations that has nothing whatsoever to do with the NPT. It's far more about how the US despite being a superpower failed to get its way. It has been a long retreat from its original aim to prevent Iran from operating nuclear powerplants to prevent it from having the technology to enrich uranium, to prevent it from actually operating centrifuges to prevent it from operating an industrial scale enrichment program to where we are today, which is basically what Iran proposed back in 2003, i.e. a system that ensures Iran's right to all technology including industrial scale enrichment while making sure that Iran does not produce nuclear weapons.
So, you cannot consider the whole brouhaha between Iran and the West in terms of just the NPT, the NPT was just invoked to fight out a conflict that would also have existed had Iran never signed the NPT. Note that the US applied pressure on the IAEA to refer Iran to the UNSC, so that the UNSC could impose restrictions on Iran's nuclear program that went beyond Iran's obligations under the NPT. The IAEA's role from that point onward was changed, it had to check if Iran was sticking to the UNSC demands. Clearly an Iran outside of the NPT would only have meant that the IAEA route not been available to the US. But nothing would then have stopped the US from raising Iran directly at the UNSC. The UNSC would have been free to impose restrictions on Iran's nuclear activities regardless of its NPT membership.
During the last decade the fundamental issue, as far as the West was concerned, was Iran's refusal to stop enriching uranium. But Iran never signed any agreement that would demand that it do so. Therefore it was Iran not sticking to a hypothetical agreement that it actually did not sign, not the NPT, that was the core issue.