That is because Allāh would not change a favor which He had bestowed upon a people until they change what is within themselves. And indeed, Allāh is Hearing and Knowing.
That severe punishment is because when Allah favours a people, He does not take it away from them until they change themselves from their pure state of faith, righteousness and gratitude to a bad state of disbelief in Allah, sin and ingratitude – Allah hears the statements of His servants and knows about their actions; nothing is hidden from Him.