I think there was more than one reason that the American president ordered his assassination. But I believe the chief reason is one that isn't spoken about, at least not in public. I believe the president had Soleimani killed chiefly to send a message to all governments that were getting on better terms with Tehran. Such governments, in President Trump's view, were openly defying his authority in international relations, and in doing so were giving clear signs they were wandering off the American reservation while on his watch.
The list of offenders is quite long; it includes the most powerful European governments, Gulf Sunni Arab ones, and India. Not to mention China and Russia openly flaunting their relationship with Iran with their recent joint naval drills, and Iraq's government often siding with Iran against the U.S.
Something had to be done to emphasize to all concerned that those who stood against the United States would regret it. Openly murdering Iran's greatest hero was one way to send the message, if one thinks like Mr Trump, who strikes me as obsessed with maintaining face.
As to whether I agree with Elijah Magnier's analysis, which is that fragmentation in the so-called 'Axis of Resistance' led to Soleimani's death -- well, I am in no position to disagree with any single part of his analysis; he is very knowledgeable about the politics of the Levant and Iran, and has good sources. But I would enjoin him to look at the picture from Washington's viewpoint. In any case, I recommend his report because it provides insights on how Soleimani thought.
I also recommend the parts of Bernhard's January 6 essay for Moon of Alabama where he corrects the record:
In their descriptions of Qassem Soleimani U.S. media fail to mention that Soleimani and the U.S. fought on the same side. In 2001 Iran supported the U.S. invasion of Afghanistan. It used its good relations with the Hazara Militia and the anti-Taliban Northern Alliance, which both the CIA and Iran had supplied for years, to support the U.S. operation. The Wikipedia entry for the 2001 uprising in Herat lists U.S. General Tommy Franks and General Qassem Soleimani as allied commanders.
In 2015 the U.S. and Iran again collaborated. This time to defeat ISIS in Iraq. During the battle to liberate Tikrit the U.S. air force flew in support of General Soleimani's ground forces. Newsweek reported at that time:
While western nations, including the U.S., were slow to react to ISIS's march across northern Iraq, Soleimani was quick to play a more public role in Tehran's efforts to tackle the terror group. For example, the commander was seen in pictures with militiamen in the northern Iraqi town of Amerli when it was recaptured from ISIS last September....
Top U.S. general Martin Dempsey has said that the involvement of Iran in the fight against ISIS in Iraq could be a positive step, as long as the situation does not descend into sectarianism, because of fears surrounding how Shia militias may treat the remaining Sunni population of Tikrit if it is recaptured. The military chief also claimed that almost two thirds of the 30,000 offensive were Iranian-backed militiamen, meaning that without Iranian assistance and Soleimani's guidance, the offensive on Tikrit may not have been possible.
It is deplorable that U.S. media and politicians blame Soleimani for U.S. casualties during the invasion of Iraq. Shia groups caused only 17% of all U.S. casualties and fought, like the Sadr Brigades, without support from Iran. There are also revived claims that Iran provided the Iraqi resistance with Explosive Formed Penetrators used in roadside bombs. But that claim had been proven to be was false more than 12 years ago.