It is as simple as Trump, personally, saw a TV pundit at 6am that said TikTok was bad and the president should do something about it.
Did someone at Facebook PR plant that story in the pundit's program, which is for sale? Sure. I don't know, who do you think gives a single fuck about giant companies fucking each other? Not a single normal person.
What will courts say? The matters could all be resolved in 10 minutes. They're just going to say that if there's a problem, it's with the way the order is written - Trump could issue another order. They articulate no legal problem with the order, because there is no legal problem with the order.
Truthfully, the court's resolution of the matter is the least interesting part here.
The president's power is being used to affect a corporate acquisition. You can go have a debate about mercantilism, it's settled. Nothing of substance to normal people will change because 100% of the spending inside social media apps is surplus, they could disappear tomorrow and absolutely nothing of value would be lost. People would just buy ad inventory elsewhere, as they always had for all of history.