Sure Al-Qasas

28:59

وَمَا كَانَ رَبُّكَ مُهْلِكَ ٱلْقُرَىٰ حَتَّىٰ يَبْعَثَ فِىٓ أُمِّهَا رَسُولًۭا يَتْلُوا۟ عَلَيْهِمْ ءَايَٰتِنَا ۚ وَمَا كُنَّا مُهْلِكِى ٱلْقُرَىٰٓ إِلَّا وَأَهْلُهَا ظَٰلِمُونَ

Und dein Herr hätte nimmer die Städte vernichtet, bevor Er nicht in ihrem Mittelpunkt einen Gesandten hätte erstehen lassen, der ihnen Unsere Zeichen verliest. Und Wir hätten die Städte nimmer vernichtet, wenn ihre Bewohner nicht ungerecht gewesen wären.

Tafsir 28:59

O Messenger, your Lord did not destroy the cities until he had given opportunity to their inhabitants by sending Messengers to their main cities, just as He sent you to the Mother of Cities. And I was not one to destroy the people of the cities when they were firm on the truth. I only destroy them when they are unjust through disbelief and committing sins.