"And Allah presents an example: a city which was secure and at peace" up to His saying: "while they were wrongdoers." The city is Mecca, and the Messenger is Muhammad. They disbelieved in the favors of Allah; they denied His Messenger and were not grateful. And His saying: "So Allah made it taste the garment of hunger and fear," means the hunger with which they were punished in Mecca before their punishment on the Day of Badr, then Allah punished them with the sword on the Day of Badr. As for the fear, it was after the Prophet (peace be upon him) had left them.
﴿وَضَرَبَ اللَّهُ مَثَلا قَرْيَةً كَانَتْ آمِنَة مطمئنة﴾ إِلَى قَوْله: ﴿وهم ظَالِمُونَ﴾ الْقَرْيَةُ: مَكَّةُ، وَالرَّسُولُ: محمدٌ؛ كَفَرُوا بِأَنْعُمِ اللَّهِ؛ فَكَذَّبُوا رَسُولَهُ وَلَمْ يَشْكُرُوا. وَقَوْلُهُ: ﴿فَأَذَاقَهَا اللَّهُ لِبَاسَ الْجُوع وَالْخَوْف﴾ يَعْنِي: الْجُوعَ الَّذِي عُذِّبُوا بِهِ بِمَكَّةَ قَبْلَ عَذَابِهِمْ يَوْمَ بَدْرٍ، ثُمَّ عَذَّبَهُمُ اللَّهُ بِالسَّيْفِ يَوْمَ بَدْرٍ، وَأَمَّا الْخَوْفُ: فَبَعْدَ مَا خَرَجَ النَّبِيُّ ﷺ عَنْهُم.