There are several interpretations of the link. We can divide it into three major interpretations.
Interpretation 1: Forbidding Unjust Marriage to Orphans
The context of the verse is a man who has an orphan girl under his care and wishes to marry her for her wealth or beauty. Allah forbade him from marrying her if he cannot do full justice by giving her the deserved mahr and treating her well. If he cannot guarantee full justice to her, he should stick to marrying other women.
Allah says: ⟪And if you⟫ feel like marrying an orphan girl but ⟪fear that you will not deal justly with the orphan⟫ girls you marry by giving them a mahr that is worthy of their status or treating them with the proper treatment wives deserve, ⟪then⟫ do not marry the orphans under your care, but rather ⟪marry those that please you of⟫ other ⟪women, two or three or four. But if you fear that you will not be just⟫ by giving the rights of each wife properly, ⟪then⟫ only ⟪one or those your right hand possesses. That is more suitable that you may not incline [to injustice].⟫
This interpretation is by Aisha (RA) and quoted in Sahih Bukhari (see here).
Interpretation 2: Forbidding Unjust Marriage in General Using the Fear of Mistreating Orphans
The context is that people at the time used to be very careful in treating orphans well and respecting their property but did not have the same care and good treatment of wives. So, Allah commands them to treat their wives fairly and limits marriage to four wives because marrying more than that would likely lead to injustice.
Allah says: ⟪And if you⟫ are cautious about treating orphans well and ⟪fear not dealing justly with the orphans⟫ due to the many severe commands regarding orphans in the Quran, then also remember to fear being unjust with women and ⟪marry those that please you of women⟫ only up to when there is no fear of injustice and that can only be up to ⟪two or three or four⟫ because marrying more than that will lead to injustice. ⟪But if you fear that you will not be just⟫ even when marrying up to four, ⟪then⟫ only ⟪one or those your right hand possesses. That is more suitable that you may not incline⟫ towards injustice against women.
This interpretation is reported from Ibn Abbas (RA), Saeed ibn Jubair, As-Suddi, Dhahhak, Qatadah, and Rabee’ in the Tafsir of Tabari. The narration from Ibn Abbas is through Ali ibn Abi Talhah. This is the interpretation that Tabari prefers as the most correct one.
Interpretation 3: Forbidding Many Marriages to Safeguard the Wealth of Orphans
The context is that some people in Jahiliyyah (pre-Islamic times) used to marry up to ten or more wives and, when that caused them financial trouble, they would be tempted to take some wealth from the inheritance of the orphans under their care. To safeguard the orphans from such injustice, Allah limited people from marrying more than four wives.
Allah says: ⟪And if you⟫ take care of orphans and ⟪fear that you will not deal justly with the orphans⟫ and might be tempted to take their money because you have too many wives to take care of, ⟪then⟫ limit yourself and only ⟪marry those that please you of women, two or three or four. But if you fear that you will not be just⟫ to the orphans even with four wives, ⟪then⟫ marry only ⟪one or those your right hand possesses. That is more suitable that you may not incline⟫ towards injustice to orphans.
This interpretation is reported from Ibn Abbas and Ikrimah. The narration from Ibn Abbas is through Atiyyah ibn Saad and Tawus. It is reported that Ibn Abbas said: “Men were limited to four wives because of the wealth of the orphans.” (Tafsir Ibn Abi Hatim)
Those are three major ways that the mufassiroon linked injustice of orphans to marriage and their opinions on why Allah connected them. See this article for a more detailed analysis of the interpretations along with a few more interpretations.
It is possible a combination of the interpretations are intended by the same verse.