When Zhu Yuanzhang established Zhu Yunzhang as the heir to the throne, he actually understood that some people would oppose Zhu Yunjiao in the future. Then, since Zhu Yuanzhang already knew that some people would oppose Zhu Yunjiao, why did he still want to make Zhu Yunjiao emperor?

(Portrait of Zhu Yuanzhang)
We said that Zhu Yuanzhang expected someone to oppose Zhu Yunjiao, and this statement is fully evidenced.
The most important evidence is Zhu Yuanzhang's unusual slaughter of the heroes.
The main reason why Zhu Yuanzhang initially killed Hu Weiyong, Yang Xian, Wang Guangyang, and others was that after these people became prime ministers, they did not take Zhu Yuanzhang seriously, formed gangs and factions in the imperial court, and acted arbitrarily. Whatever happens in the imperial court, you must decide for yourself. Sometimes they also use the convenience of power to exclude dissidents and gain benefits. In doing so, Zhu Yuanzhang felt that his imperial power was seriously threatened, so he took down Hu Weiyong, Yang Xian, Wang Guangyang and others one after another. And through the treatment of them, warn those ministers who want to seize power in the imperial court, do not have such thoughts.
In order to avoid such a thing from happening again, Zhu Yuanzhang simply abolished the position of prime minister.
However, when Zhu Yuanzhang dealt with Li Shanchang and Lan Yu and others, he was already not to ensure the stability of his throne, but to ensure the stability of Zhu Yunjiao's throne in the future. His treatment of Li Shanchang was to adopt additional punishment. That is to say, Li Shanchang originally had nothing to do, but later, Zhu Yuanzhang said that Li Shanchang's account had not yet been calculated for him, and he had to continue to calculate, so he put Li Shanchang and a large number of other meritorious men to death.
He executed Blue Jade and turned Blue Jade's crime into a book called "Records of Rebellion". In this way, it is shown that the crime of blue jade is really the most heinous crime. But in fact, if those crimes are taken out and said, it seems that every one of them is not on the list, and there is a little taste of sin that wants to be added. It can be seen from this that Zhu Yuanzhang really did these things to ensure the stability of Zhu Yunjiao's throne.
(Portrait of Zhu Yunjiao)
In addition to fearing that the heroes would pose a threat to Zhu Yunjiao's throne, Zhu Yuanzhang was actually worried that his sons would pose a threat to Zhu Yunjiao's throne. To this end, he made many rules for his sons, such as not allowing him to enter Beijing casually without the consent of the emperor. For example, even if the king of the clan wants to enter the capital, he can only come one by one, and cannot go together. For example, the kings of the clan are not allowed to visit each other's doors, and so on.
These measures stipulated by Zhu Yuanzhang were a kind of restriction on the kings of the clan. He believed that as long as the clan kings acted strictly in this way, they would never pose a threat to the central government.
Of course, although Zhu Yuanzhang was also worried that his sons would oppose Zhu Yunjiao and would rebel. But compared to the heroes, such worries are not great. Therefore, under the stipulation that the kings of the clan were not allowed to walk around randomly, Zhu Yuanzhang made another provision. That is, when there were ministers in the capital who tried to threaten the imperial power, the princes of the clan had the right to raise troops into the capital "Qing Jun's side". It can be seen from this that Zhu Yuanzhang's precautions against the ministers were obviously much stricter than those against the princes of the domain.
Then, Zhu Yuanzhang already knew that the imperial power of his grandson Zhu Yunjiao would definitely be threatened, so why did he pass the throne to Zhu Yunjiao? If he hadn't passed it on to Zhu Yunjiao at that time, but to other sons, wouldn't the threat to the imperial power be less severe, and he wouldn't have had to kill the heroes so much, nor did he have to restrict and guard against the kings of the clan like that?
(Portrait of Zhu Di)
I think that the reason why Zhu Yuanzhang did this is based on the following considerations.
First, Zhu Yuanzhang believed that those who were threatening heroes had been almost cleaned up by him. The ministers who stayed behind were all people who were loyal to Zhu Yunjiao. As for the ministers he promoted himself after Zhu Yunjiao came to power, he did not need to consider them. Because these are Zhu Yunjiao's most loyal people. Therefore, the threat of the ministers to Zhu Yunjiao has actually been lifted.
In fact, if the ministers were a threat, then whether it was zhu Yunjiao as emperor, or Zhu Di or other sons as emperors, the threat still existed. So for him, passing the throne to whomever he passes on the throne means the same thing.
Second, the threat of border passes does not exist. After cleaning up the generals such as Lan Yu, he would definitely worry about the instability of the border. However, before Zhu Yuanzhang's death, he had already sent troops to pursue the Mongols eight times, so that the Mongols were no longer able to launch large-scale invasions. At the same time, Zhu Yuanzhang also installed Zhu Di, Zhu Quan and other Sai kings on the border gate. These Cypriot kings can effectively deter aggression. So it doesn't have to be considered.
Third, the threat of the clan kings to Zhu Yunjiao, Zhu Yuanzhang, of course, also considered. That's why he made that rule. However, from Zhu Yuanzhang's point of view, he did not think that his descendants would fight and fight for the throne. Therefore, the precautions are also the lightest.
In short, Zhu Di's efforts to ensure that Zhu Yunjiao can sit firmly on the throne can be said to be painstaking, and all aspects have been taken into account. It's just that the slightest problem he thinks has become a major hidden danger in the later seizure of Zhu Yunjiao's country, which is unexpected by Zhu Yuanzhang.
(References: History of the Ming Dynasty, Ming Shilu)