If Musk lost in court, was ordered to go through with the deal, and then sabotaged the financing to try to get out of the deal, potentially a court could have thrown him in jail and said, "You are lying about not being able to go through with the financing, we find you in contempt of court and you are staying in jail until you obtain financing and close the deal." It's not very plausible that the world's richest man can't find financing on the deal.
Potentially a court could have also instead said, "Since you sabotaged the financing, you are in breach of contract. Twitter is worth 22 billion dollars today. You offered 44 billion dollars to buy it. You are hereby ordered to pay Twitter 22 billion dollars to make them whole." Presumably the court could have forced him to sell assets to pay up.
I don't think anyone knows for sure what would have happened in court but it seems he had a very weak case.
On it being a questionable deal, it’s not a consumer contract. It is assumed that both sides know what they’re doing in commercial deals; there’s little protection for incompetent participants. It might be questionable, but the participants have largely signed away the right to question it.