There is not to be upon the Prophet any discomfort concerning that which Allāh has imposed upon him. [This is] the established way of Allāh with those [prophets] who have passed on before. And ever is the command of Allāh a destiny decreed.
(There is no blame on the Prophet in that which Allah has made legal for him.) means, in that which has been permitted for him and which he has been commanded to do, i.e. his marrying Zaynab, may Allah be pleased with her,, who had been divorced by his adopted son Zayd bin Harithah,
سُنَّةَ اللَّهِ فِى الَّذِينَ خَلَوْاْ مِن قَبْلُ
(That has been Allah's way with those who have passed away of old.) means this is the ruling of Allah for the Prophets who came before him. Allah would not command them to do anything for which they might be blamed. This is a refutation of those hypocrites who imagined that there was anything wrong with his marrying the ex-wife of Zayd, his freed slave and adopted son.
وَكَانَ أَمْرُ اللَّهِ قَدَراً مَّقْدُوراً
(And the command of Allah is a decree determined.) means, His command which He has decreed must inevitably come to pass; nothing can prevent it or avert it, for whatever He wills happens, and whatever He does not decree, does not happen.
Ma'arif al-Qur'an
Mufti Muhammad Shafi
Prefacing an answer to doubts and objections
The opening sentence of verse 38: سُنَّةَ اللَّـهِ فِي الَّذِينَ خَلَوْا مِن قَبْلُ ۚ وَكَانَ أَمْرُ اللَّـهِ قَدَرًا مَّقْدُورًا (a customary practice of Allah in the case of those who have gone before--- And Allah's command is pre-determined by destiny - 38) is a preface to doubts to be encountered in the wake of this marriage, particularly about why so much concern was shown in the case of this marriage despite there being other wives in the household. It was said: 'This is a sunnah of Allah (His customary practice not restricted to Muhammad al-Mustafa t. It has continued to be so in the case of earlier prophets as well, that is, under the dictate of beneficial religious considerations, permission was given for multiple marriages. Well recognized among them are Sayyidna Dawud (علیہ السلام) and Sayyidna Sulaiman Sayyidna Dawud (علیہ السلام) had one hundred wives in his nikah and Sayyidna Sulaiman (علیہ السلام) ، three hundred. Now, if permission came for the Holy Prophet ﷺ to have several marriages under beneficial religious considerations - this nikah being included therein - why should it be taken as something far-fetched? Neither is it contrary to the dignity and status of a prophet and messenger of Allah, nor against the norms of zuhd and taqwa. In the last sentence, it was also said that the matter of nikah (marriage) too, like that of rizq or sustenance, is Divinely decided as to who will be married to whom. That which is written in the eternal destiny has to occur. In this event relating to Sayyidna Zayd ؓ and Sayyidah Zainab ؓ the factors of their mutual temperamental difference, the displeasure of Sayyidna Zayd ؓ and then his resolve to divorce her were all chains of this very creational and destined imperative.
Tazkirul Quran
Maulana Wahiduddin KhanOn ayahs 37–39
Zayd’s marriage with Zaynab took place in the year 4 AH, but the marriage was a failure and the next year they separated. When Zayd expressed to the Prophet, his intention of giving a divorce in this case, the Prophet of God asked the reason for it. Zayd said that she had a superiority complex over him due to her being from a noble family. However, the Prophet Muhammad urged him not to divorce her. However, on Zayd’s insistence, he permitted them to separate. When Zayd and Zaynab got married, they broke an old convention and it was ordained that a difference in social status should not come in the way of marriage. But when they separated, it was the will of Almighty God that Zaynab should be made the means of breaking yet another erroneous custom. By tradition, in the old pre-Islamic period, an adopted son was treated just like a real son, enjoying the same rights and titles. The best way of breaking this custom was that after her divorce, Zaynab should marry the Prophet Muhammad. Zayd was the adopted son of the Prophet Muhammad, and was known as Zayd bin (son of) Muhammad. Under these circumstances, the Prophet’s marrying the divorced wife of his adopted son amounted to a disastrous contravention of the old custom, which held that a man’s marrying a woman formerly married to his adopted son, and then divorced by him, was prohibited because she was no different from a woman married to and then divorced by his real son. The Prophet Muhammad was told in advance that if there should be a separation between the aforesaid couple, then as a device to break the old pre-Islamic custom, Zaynab would be given in marriage to him. Since such a marriage in the prevailing atmosphere would have given him a bad name, the Prophet urged Zayd not to divorce Zaynab, so that he might be spared this very trying ordeal. But, whatever was ordained by God, did happen. Zayd divorced Zaynab and, so as to break the old custom, Zaynab was married to the Prophet in the year 5 A.H.