Iran is a country without an alternative. credible way to threaten an adversaries manufacturing/population centres. The likely potential enemies are all situated beyond it conventional force range, and they have zero expeditionary capability. A small warhead SRBM would be better than nothing.
The apparent threat facing Iran’s regime at the time they really started investing money in their ballistic missile program was the EU, Israel, and the US, with the US/NATO having military forces fencing them in on three sides during the 2000s. Looking at it objectively a deterrent oriented program with secondary but limited offensive capabilities seems prudent.
A rudimentary ballistic missile program, would mature over time, help develop an modern military manufacturing base, and could also eventually lead to a space launch capability. That’s exactly what the missile programs in the US and Soviet Union did.
If an invasion did happen they had no way of striking back with their conventional forces. A ballistic missile program would at least give the appearance to its own citizens of being able to strike back at an invading enemy.
The civilian propaganda value of most of Iran’s military programs cannot be understated. The Qahir 313 fighter/toy model, battle buses, “copies” of US stealth drones, Main Battle Tanks, and ballistic missiles. All look like they have limited military usefulness to informed eyes, but to uninformed civilians they are a source of pride and comfort.