Sure Al-An'aam

6:131

ذَٰلِكَ أَن لَّمْ يَكُن رَّبُّكَ مُهْلِكَ ٱلْقُرَىٰ بِظُلْمٍۢ وَأَهْلُهَا غَٰفِلُونَ

Das (ist so), weil dein Herr die Städte nicht zu Unrecht vernichtet', während ihre Bewohner unachtsam sind.

Tafsir 6:131

The reason for sending messengers to mankind and jinn is so that no one is punished for the crimes they committed without a messenger having been sent to warn them and the invitation reaching them. I only punished a nation after sending messengers to them.