He did it to humiliate him. He gave McCarthy false confidence while the MAGA representatives played their roles and tore into him like wolves, exposing him throughout the 9 vote attempts. It was Trump's gift to MAGA reps, and they feasted.
This is similar to Trump putting Fauci in the spotlight to expose him. Except much more cruel in the way he really convinced McCarthy he was an ally.
About the vote for Trump as Speaker, I think of when Q said "Those who have not resigned have been put into submission." Maybe this is where the subdued RINO's are activated by white hats and vote for Trump. It would be a shock to the cabal rivaling the 2016 election.
Who really knows, but that’s where my thoughts go as well