فَجَعَلْنٰهَا نَكَالًا لِّمَا بَيْنَ يَدَيْهَا وَمَا خَلْفَهَا وَمَوْعِظَةً لِّلْمُتَّقِيْنَ ( البقرة: ٦٦ )
Faja'alnaahaa nakaalal limaa baina yadihaa wa maa khalfahaa wa maw'izatal lilmuttaqeen (al-Baq̈arah 2:66)
And We made it a deterrent punishment for those who were present and those who succeeded [them] and a lesson for those who fear Allah. (Al-Baqarah  : 66)
1 Mufti Taqi Usmani
Thus, We made it a deterrent for those around and (those who came) after them - and a lesson for the God-fearing.