Elsewhere IIRC analysts have provided explanations as to why Iran has gone down the nuclear weapons route and that I suspect is largely built around hostile neighbours with US military facilities.
Originally it was a response to the threat of Iraq and an Iraqi nuclear program. Obviously, Iraq is no longer a threat, so, assuming the program still exists, what is its purpose today? Perhaps the US and Israel have replaced Iraq as justification. Isolation is probably a big factor - Iran does not have have a great-power protector willing to extend a nuclear umbrella to protect it. Iran may aspire to become a great power itself. Alternatively, Iran's program my continue on the basis of inertia - in other words, it became institutionalized. The reasons are probably all of the above in some form or another.