The most fundamental thing to understand about imperial China is that emperors had absolute power. They were gods. They were the law. They owned the whole of China. I tried to find an equivalent in western history and I couldn’t. Not even Louis XIV.
A general knew that an attack was suicide. But if the emperor ordered him to attack, he attacked. In the most extreme cases, an emperor could order someone to kill themselves, and the person would do it. Maybe they cried, but they did not refuse or complain.
Even small kingdoms (like those in the Yakko song). Even illegitimate regimes. When a rebel leader declared himself emperor, he suddenly had that same power. Maybe this is why the Mongols and Jurchens did not want to leave.