Blessings come with Faith, while Kufr brings Torment
Allah mentions here the little faith of the people of the towns to whom He sent Messengers. In another instance, Allah said,
فلوﻻ كانت قرية ءامنت فنفعها إيمانها إﻻ قوم يونس لما ءامنوا كشفنا عنهم عذاب الخزى فى الحيوة الدنيا ومتعناهم إلى حين
Was there any town (community) that believed (after seeing the punishment), and its faith (at that moment) saved it (from the punishment) -- Except the people of Yunus; when they believed, We removed from them the torment of disgrace in the life of the (present) world, and permitted them to enjoy for a while. (10:98)
This Ayah indicates that no city believed in its entirety, except the city of Prophet Yunus, for they all believed after they were stricken by punishment.
Allah said (about Prophet Yunus),
وأرسلنه إلى ماية ألف أو يزيدون
فامنوا فمتعنهم إلى حين
And We sent him to a hundred thousand (people) or even more. And they believed; so We gave them enjoyment for a while. (37:147-148)
Allah said in another Ayah,
وما أرسلنا فى قرية من نذير
And We did not send a warner to a township.... (34:34)
Allah said here,
ولو أن أهل القرى آمنوا واتقوا
And if the people of the towns had believed and had Taqwa...
meaning their hearts had faith in what the Messenger brought them, believed and obeyed him, and had Taqwa by performing the acts of obedience and abstaining from the prohibitions,
لفتحنا عليهم بركات من السماء واﻻرض
We should have opened for them blessings from the heaven and the earth,
in reference to the rain that falls from the sky and the vegetation of the earth.
Allah said,
ولكن كذبوا فٲخذناهم بما كانوا يكسبون
but they belied (the Messengers). So We took them (with punishment) for what they used to earn.
They denied their Messengers, so that We punished them and sent destruction on them as a result of the sins and wickedness that they earned.
Allah then said, while warning and threatening against defying His orders and daring to commit His prohibitions,