And that He might make evident those who are hypocrites. For it was said to them, "Come, fight in the way of Allāh or [at least] defend." They said, "If we had known [there would be] battle, we would have followed you." They were nearer to disbelief that day than to faith, saying with their mouths what was not in their hearts. And Allāh is most knowing of what they conceal -
(When a single disaster smites you), in reference to when the Muslims suffered seventy fatalities during the battle of Uhud,
قَدْ أَصَبْتُمْ مِّثْلَيْهَا
(although you smote (your enemies) with one twice as great,) during Badr, when the Muslims killed seventy Mushriks and captured seventy others,
قُلْتُمْ أَنَّى هَـذَا
(you say: "From where does this come to us") why did this defeat happen to us
قُلْ هُوَ مِنْ عِندِ أَنْفُسِكُمْ
(Say, "It is from yourselves.") Ibn Abi Hatim recorded that `Umar bin Al-Khattab said, "When Uhud occurred, a year after Badr, Muslims were punished for taking ransom from the disbelievers at Badr in return for releasing the Mushriks whom they captured in that battle. Thus, they suffered the loss of seventy fatalities and the Companions of the Messenger of Allah gave flight and abandoned him. The Messenger suffered a broken tooth, the helmet was smashed on his head and blood flowed onto his face. Allah then revealed,
Immediately later, in verse 166, the words fa bi idhnillahi: فَبِإِذْنِ اللَّـه indicate that whatever happened there was with the leave and will of Allah Almighty operating behind which are many wise divine arrangements, some of them having been explained earlier. One such wise arrangement is that Allah will 'see' His true believers, and the hypocrites too, that is, the sincerity of Muslims and the hypocrisy of the hypocrites will become so clear that everybody could see it for himself. Here, the reference to Allah's knowing or seeing means seeing in the perspective of our own sense-experience in the mortal world. Otherwise, as far as Allah is concerned, He knows and sees everything, all the time. So, the wise arrangement became all the more clear when, at the time of the trial, the hypocrites bowed out of the harm's way while true Muslims stood undaunted' in the middle of the battle front.
Tazkirul Quran
Maulana Wahiduddin Khan
In the confrontation between truth and untruth, truth is always destined to have the final victory, because truth always has God on its side. However, this world being a world of trial, mischief-mongers too have full freedom of action. That is why at times, by exploiting some weakness of the believers—for instance, mutual dissension—they are able to inflict temporary harm on them. Yet such happenings, though tragic in appearance, have a good side to them as well, for in this way Muslims are put to the test. In the face of unfavourable situations, the insincere fall away, while the true believers persevere because of their total trust in God. In this way, it becomes clear who are the trustworthy and who are not. Furthermore, God’s mercy is all the more focussed upon them, when, after incurring loss due to their inadvertent mistakes, the believers turn to God once again in all patience and humility.
Uthmani text of the Madinah mushaf (King Fahd Complex). Translation: Saheeh International. Tafsir via Quran.com.