According to the 10 Commandments, the people of those cities were sinning,. Thus, they were "breaking the law of the land" and "had" to be
punished by God.
Why they couldn't repent, or be forgiven by God, is another issue.
But if you were one who is manhandled, abused against your will, bullied, beaten, trod up, spat on, discriminated upon, murdered or sacrificed, or worse, seeing all these happening to your loved ones...
Deuteronomy
24 They shall be burnt with hunger, and devoured with burning heat, and with bitter destruction: I will also send the teeth of beasts upon them, with the poison of serpents of the dust.
25 The sword without, and terror within, shall destroy both the young man and the virgin, the suckling also with the man of gray hairs.
26 I said, I would scatter them into corners, I would make the remembrance of them to cease from among men: 27 Were it not that I feared the wrath of the enemy, lest their adversaries should behave themselves strangely, and lest they should say, Our hand is high, and the Lord hath not done all this.

The were both cities of vice and sexual freedom. Did he have any right imposing his system of morality and justice on them? Was this an act of Terrorism by God?