A fascinating question because I used to intentionally make my characters Mary Sues. As a former child who used to write, for a while I never understood why people would give character traits they disagree with to the character or characters who are supposed to represent what is right in your world, since they’re the ones unfolding the story’s solution. This had the side effect of my main character being nicer than me, and sometimes my parents would remark to me “why can’t you be like your main character”, which had the side effect of putting me on the fast track to self-improvement. Anyone else?
It depends on the character. I never write perfect characters. Most of my characters are extremely flawed individuals whose flaws lead to the issues in the story, or contribute to a wider plot of some kind. I look at real people and ideals, try to get on their side even if I hate it, and make a character with those viewpoints. One thing all my characters have is sacrifice and the chance of redemption. All of my characters go through some sort of personal sacrifice to achieve their goals, not all of them redeem themselves even if there is always the chance. I do make that pathway visible to the reader. I feel it gets people in the mindset of a complete other, or at least helps them make sense of a differing thought process. And yes, I make doubly sure to do this with characters who are designed to be hated.