It is a bad deal, and Iran's leadership has a bad strategy, perhaps isn't even fully invested in the well-being of the nation. If it was, it would not compromise on deterrence, especially nuclear deterrence.
The reason Iran went down this path of indecision and half-hearted effort vis-a-vis the nuclear issues is manifold. Foremost, there is a large contingent of Iranian politicians, tied to neoliberal oligarchs in Iran that have ties to the West, to banking elites, and have many family members and moreover property in the West, and these priorities matter more to them than the wealth and well-being of Iran. This is what people mean when they say Iran's system is corrupt. Much like the Shah's family pilfered the nation, The Islamic Republic's liberal wing is exactly like this as well.
Secondly, these receptive elements are compromised by Western intelligence agencies. There are willing avenues for compromise in Iran because of the nature of the system- the infighting, the corruption, the lack of opportunity, the lack of economic power- all of these make it lucrative for Iranians up and down the ladder of power to make deals with enemies of Iran for their own gain. Why do you think so many Iranian people who get a doctorate or engineering degree go to Canada or the USA?
Thirdly, Khamenei is a balancer. He's not an ideologue. He has to keep up appearances while playing a game of chess to ensure his power and that of his clan/cronies are intact, and this means playing off the various centers of power within the system against each other. He knows the liberals have their ties to Western intelligence, and they have their contingency plans should the hardliners take over, or worse, should Khamenei decide to threaten their interests. Likewise, he knows the hardliners have ways to assert themselves, too. He has to balance his power and the sustainability of the system as a whole in this context, while also ensuring society is ordered and stable enough for it all not to go to hell in a handbasket. This creates a situation of deadlock, inertia, malaise and decay.
Fourthly, masses in general are unthinking, self-interested, and suggestible. There are many Iranians in Iran right now, most of which do not know a think about regional or international politics, or how to govern a country or manage an economy. There are Iranian politicians in survival mode, thinking of the next ten or twenty years. Iran's enemies think of the next 100 or 200 years. In the case of Israel, its messianic ruling elite thinks in terms of 1,000 years. Your average Iranian citizen is thinking of bread right now, a little hal-kardan, and maybe a nicer house or apartment. The Islamic Republic should have thrown them the bone of the non-mandatory hijab and other unimportant amenities to keep them satisfied, but it couldn't- hardliners saw that as a dangerous precedent, liberals saw it as an opportunity to demand more concessions, uproot the existing order and place themselves at the top. The key here is: no one in the system is thinking about Iran. They are thinking about their goals, their power, their assets, and their foreign backers. And the Iranian people themselves- the majority- are not thinking about the future of the country. If they were, they'd make common cause with the many in the armed forces and other government institutions that are seeing the country flinging at high speed toward oblivion and are frustrated. This is because sanctions, foreign influence, and the immiseration of daily life under mismanagement of the Islamic Republic has rendered people apathetic, helpless, and hopeless. They'd rather abandon the sinking ship that try to plug the holes.
I do not digress, I make a central point here. Neither the leaders nor the people of Iran are invested enough in a real way into the nation. This nuclear issue would have been a no-brainer, a done deal by now. Leadership decided to use it as a bargaining chip and not gone for it. This is because they aren't serious about the nation, caught up in the squabbles of their own purposes and intra-system conflict. "How much can we gain from the West?" At some point, you realize there's no point to this, enough damage has been done and you cannot crawl out of the hole- at some point, you decide the best and only choice is to go full-speed toward the nuclear weapon and at least attain the deterrence your people have suffered for decades for.
Accepting the deal was bad for Iran by all counts. Maybe not "bad" if you think in the short-term, or are divorced from the reality of Iran's enemies and geopolitical position, it's history even. But in the long stretch and at the root, accepting any deal that puts Iran's deterrence and survival on hold for any stretch of time is a bad deal, and it's a testament to the failures of Iran's system.