This is a little (or a lot) meta, but I think Michael was the way he was for two reasons.
As noted, he was a shitty boss and a great salesman. He never should have been promoted.
Michael had crippling insecurity. He wanted everyone, everyone, everyone to like him. The meta part is, well, the metaplot. Michael was on camera all the time and so he had to be ‘on’ all the time. His entire life became a nightmarish compulsion to vamp for the film crew and the future audience, to impress who knows how many viewers, to make everyone in the world love him.
So in my head, Michael would have been much less of a pill if they’d picked a different DM branch to film at. Instead of trying to make everyone happy, he could have focused on making just his own staff happy. I think that’s all he really wanted, and I think he could have pulled it off.
In the episode Branch Closing, when Josh Porter is about to take over as manager of the newly merged Scranton/Stamford branch and announces that he’s leveraged this job to an even better one with Staples, Jim gives a pretty good summary: “Say what you will about Michael Scott, but he would never do that”.
And while Michael did seem serious about wanting to become a father, only an idiot couldn’t see from the start that Pam’s mom was not a candidate. His reaction to learning her age was more out of idiotic vanity, like his frequent expressed desire to date models.
Another great moment I remember was when nobody came to Pam’s art gallery exhibition, not even Jim or her fiancée. But Michael did and was genuinely blown away by her talent, and even bought a painting of their office building to put in the office. She was overwhelmed with gratitude and he was surprised by the reaction; for once he wasn’t doing anything to be liked, he was just being honestly supportive and appreciative of her.
His character had those little nuggets of humanity hidden among the other 90% of the time when he was a foolish asshat.
I seem to recall a few episodes where other people tried to run the Scranton branch temporarily and ended up failing. For some reason, Michael Scott’s bizarre management style seemed to actually keep the eccentricities of Scranton employees in check.
It’s been awhile since I’ve seen The Office, but I believe they also softened Michael Scott’s character over the years. Less cluelessly cruel.
Not directed at the OP but there is definitely a new strain of “Michael Scott wasn’t that bad!” and “Jim and Pam are the real villains on the Office.” among the fandom…and it is…gross. Like people complaining about pineapple on pizza at this point.
Michael is an idiot and incredibly toxic. He does have some good moments (the art show and his relationship with Erin) and some worthwhile traits (he is a good salesman and can be loyal)…but he’s pretty awful as a person. He does get better but it’s the influence of Holly over everything else I think.
We might understand WHY he is the way he is… but it doesn’t excuse it.