I tend to see such OT judgments as God preventing flare-ups of the kind of wickedness which precipitated the flood, not as arbitrary wipe-out of folks because they were opposed to Israel (he left many opponents of Israel to test them, and at times to judge them as they had been used to judge others).
I see God shaping mankind as a corporate entity, teaching lessons to the entire human consciousness through the ages and the generations and the dispensations of law and the rising and falling of kingdoms and empires.
When it is written of Sodom, “The smoke of her torment rises forever”, I believe this is a testimony to the witness of God’s judgment of that level of sin smoking in the corporate consciousness of mankind as a continual witness to the divine nature and eternal power of God(as with the Flood). Likewise, I believe the cross of Christ is the ultimate testimony in the corporate consciousness of man- a testimony of that very same death in Sodom being swallowed up by immortality- “O death where is thy sting”.
Paul says of the OT in 1 Corinthians 10, “these things are written for our example that we should not fall after the same example of disobedience”.
I think in part, YHWH has done these things, not so much to teach us versions of who He is (as an awesome judge, loving Father, faithful Creator, patient Potter, etc.), but to teach us, as we grow into free inheritors of His estate, why absolute justice can only exist when absolute judgment is conquered by absolute mercy- to experience both, so that we can be in true fellowship with Him, not just as our Benefactor and Source, but as mature Sons and Daughters sharing ages of co-inherited world shaping with Him in one mind and accord. To cause us to “absorb” the divine nature, and become truly righteous, and truly merciful.
Acts 17:4 The God who made the world and all things in it, since He is Lord of heaven and earth, does not dwell in temples made with hands; nor is He served by human hands, as though He needed anything, since He Himself gives to all people life and breath and all things; and** He made from one man every nation of mankind to live on all the face of the earth, having determined their appointed times and the boundaries of their habitation, that they would seek God, if perhaps they might grope for Him and find Him,** though He is not far from each one of us; 28 for in Him we live and move and exist, as even some of your own poets have said, ‘For we also are His children.’ Being then the children of God, we ought not to think that the Divine Nature is like gold or silver or stone, an image formed by the art and thought of man. Therefore having overlooked the times of ignorance, God is now declaring to men that all people everywhere should repent, because He has fixed a day in which He will judge the world in righteousness through a Man whom He has appointed, having furnished proof to all men by raising Him from the dead.”