Or at least learn to keep your mouth shut, no matter what anyone tells you to the contrary.
I would modify this: "learn to support your boss, and make them look good in front of their peers."
I've had situations where my boss and I didn't get along.
In one case that led to a dismissal with a very comfortable severance, which I believe was because while I wasn't a good fit, my boss respected me and bore no ill will toward me.
In another case my boss was openly hostile to me even in front of my peers both inside and outside the organization almost from the first day; I survived about three years there because I was effective and did my best to keep our disagreements behind closed doors. Everyone knew that my boss and I didn't get along, but I did the job well and took every opportunity to make them good and make the best of their strategies and decisions. Over time I developed a reputation for having strong opinions, a strong personality, but being very easy to work with. I learned a lot during that time, built lifelong professional relationships, and believe that I changed a few lives through mentorship of those with less experience.
I will always be frank with my immediate boss; the cost of not doing so is too high for me. I'm also clear that I see my job as contributing to the company's success, and that I see their voice on my behalf as my most effective means of impacting the organization's direction. I recognize when I don't have the final say on something, and while I'll not pretend that I support something I don't, it's their job to determine strategy, not mine, and that I'll execute their strategy to the best of my ability and without grumbling about it - and without undermining them.
Of course there are some people who simply cannot accept that the people who report to them have opinions contrary to their own or believe that they are making a mistake. I don't want to work for those people. There are too many good jobs doing things that will change the world for me to spend my time being unhappy and working on something I don't think matters.
Results are what matter and also build your value. Being known as the guy, gal or nonbinary who did X is way better than "just went along with using a massive spreadsheet as a database because the boss doesn't trust software he hasn't paid for and won't spend money on sonething he doesn't know how to use."
Or, even better, find a position in a company where you don't have to "learn" those things.
He can still make your work life difficult. But if he goes to far, HR has to consider that maybe he should leave, since they cannot make you leave without cause.
AT WILL STATE - I live in Pennsylvania and you can be fired for no reason. Sure you can sue and you might win but probably not. Why we allow these laws in a Democracy/Republic is mind blowing.
I disagree with your assessment, and fully support "at will" employment.
What is your perception as to how many people agree with you versus disagree?
So you "Don't want to work with a person" means you should be able to fire them for your emotional good? That sounds horribly selfish and an environment people wouldn't want to work in.
Most people spend more time with their coworkers than their spouse.
We even make ex-spouses pay support. Or let them live in the common house for a bit.
strong labor market and low unemployment.
If you value being able to feed your family, learn to love your boss and his ideas.