Why is Islam so behind with times? Christianity used to be hardcore and did similar things but most has fallen out of practice.
To be fair, the Byzantine Empire imprisoned/mutilated/exiled people because they were causing global unrest, as any doctrine that was seen as a heresy and that was spreading over the empire was seen at the same time as a rebellion against the emperor. Even some saints were seen as heretics by the imperial court and were therefore imprisoned/mutilated/exiled, like Maximus the Confessor. The aspect was as much political as it was religious, and even on a religious level it was not stuff on the level of "can women not wear headscarves?" and rather stuff on the level of "is Jesus God?".
It's a little funny that in the end, having Christianity as the state religion did not bring stability at all, as it took 9 centuries for the major doctrines to be laid out clearly enough, meaning there was a lot of confusion and unstability until then, and there was rarely ever a time when there weren't major heretical groups causing disputes and such. That's what happens when there is no real central authority, doctrinal dialogue is tolerated and even encouraged sometimes, and the emperor is expected to deal with the practical stuff but he himself wasn't always orthodox.
And now that I think about it, this is likely the case here too. I mean, that this is political as much as it is religious. Promoting that women shouldn't be forced to wear a hijab is not seen only as an act of apostasy and an attack on religion, it may also be seen as a "trojan horse" by which Western values can infiltrate and destabilize Iran. Therefore they are fearless to give her such a harsh punishment and to let everyone in the world know.
I'll remind, of course, that the Quran says that there is no compulsion in religion. I do not think that there is something in Islam that fundamentally prevents a dialogue on the hijab, even if I doubt the end result would be much different from the beginning. But Islamic theocracies have an iron grip on their nations and they will not take the risk of heresies destabilizing them, especially if these heresies can be framed as proxy attacks by the West.
Incidentally, even though I'm not a fan of the ancient Islamic empires, they were actually quite tolerant if we compare them to most Islamic nations today.