Ibn al-Qayyim said:
“Allah sometimes gives the earth permission to breathe, which is when major earthquakes happen; this makes people feel scared, so they repent, give up sins, pray to Allah and feel regret [for sins].
When there had been an earthquake, some of the Salaf said:
this ayah is a call to those who have wronged themselves through sin not to despair of Allah's mercy. it reminds them that no matter how far they've gone, the door of repentance remains open. Allah calls them back to Him with hope, not hopelessness.