When entering management, one piece of advice you may receive is that "your job isn't to be liked." When I was internally interviewing for my first management position, our area lead (a senior director) handed me this knowledge. It's even Thing #97 in 97 Things Every Engineering Manager Should Know. If you're like me and prefer to flip to the end of books in the book store, it'll be the first thing you see! Ultimately, I think this is really important advice, but I feel there is extra nuance that folks often miss when doling out this piece of wisdom.
The underlying purpose of this tenet is to convey that "success" as a manager is much more than being liked by your direct reports. In fact, seeking out being liked can be problematic because it means you may avoid parts of your job, such as giving difficult feedback to your reports. This ultimately stunts their growth, and may set them up for failure. Kim Scott, author of Radical Candor, tells the story of Bob, a floundering employee, and how she failed to deliver much-needed feedback to him until her more-productive employees finally told her "either you fire him, or we're leaving." Trying to be liked may also mean not giving bad news to leadership or stakeholders because you don't want to disappoint them. This can result in a missed deadline, which has a really rough impact that could have been avoided or mitigated if you were upfront about the issues.
I've seen a few managers take this too far the other direction: "Just because my team doesn't like me doesn't mean I'm doing a bad job." These managers think they're just "telling it like it is, because the team needs to hear it," but they're really just coming off as jerks. It's also true that sometimes you'll have to make a decision where you say "the team won't like this decision, but I know it's for the best." Usually, this would be a decision like bringing your team on-call, a reorganization, or other changes that you know nobody will be thrilled about. This can be effective some of the time, but it can't be successful if that's the default mode of thinking. You have smart team members that report to you. Let them do their jobs!
Trust. You can only balance likability and unpopular decisions if your team trusts that you are capable, and that you've weighed the consequences of those decisions. If you make decisions without consulting with your team, or constantly go against their wishes, you risk straining this trust, and ultimately, causing your team members to leave. Or maybe even worse yet for you, them talking to your manager about how you're not doing your job properly. Either way, it's not a good outcome for you.
How do you build that trust? You build trust by first trusting your team. If they tell you something hadn't worked in the past, listen to them. If they tell you something isn't working, take a look at the evidence they are showing you. If they say they're getting burnt out, figure out how to help them. After your team knows you care about their well-being and careers, then it can be possible to make unpopular decisions and still have your team stick with you.
And please, please measure and react to those decisions. Make sure you have proof when you say "see, this is working," or be open and admit "you were right, this wasn't the right choice." I once watched a C-level executive lose his job after doing a massive shift in how the company worked. Everyone complained, attrition was widespread, and his ultimate goal of faster delivery wasn't met (delivery was, in fact, slower). He never decided to shift gears even after presented with all that evidence, so they fired him after a year of not listening to feedback.
So yes, being liked shouldn't be your goal, but I've found it to be a byproduct of being trusted by your team.