There has certainly been for you in them an excellent pattern for anyone whose hope is in Allah and the Last Day. And whoever turns away - then indeed, Allah is the Free of need, the Praiseworthy.
Tafseer
{ لقد كان لكم } يا أمة محمد جواب قسم مقدر { فيهم أسوة حسنة لمن كان } بدل اشتمال من كم بإعادة الجار { يرجوا الله واليوم الآخر } أي يخافهما أو يظن الثواب والعقاب { ومن يتول } بأن يوالي الكفار { فإن الله هو الغني } عن خلقه { الحميد } لأهل طاعته .
{Indeed, you have} O nation of Muhammad, this is the answer to an implied oath {in them is a good example for whoever} is a substitute for inclusion from “how many” by repeating the preposition {hopes for God and the Last Day} that is, fears them or thinks of reward and punishment {and whoever turns away} by turning away from the disbelievers {then indeed, God is the Self-Sufficient} from His creation {the Praiseworthy} to those who obey Him.