To paraphrase someone (I’m not sure who): ‘A good man is remembered for his best moments; a bad man by his worst’.
Implicit in this truism is the acknowledgement that most everyone has two sides to their personality, but also that one side is usually dominant. In fiction, a character's personality will comprise mostly positive traits or mostly negative ones. But it’s important to have a mix. A character too weighted to one side or the other is likely to be seen as, at best, poorly developed; at worst, as a silly caricature. We’re all familiar with the dastardly villain who’d gladly sell his grandmother to the dog-food factory and his pet poodle to the furriers, but such people often have a cartoonish aspect to them that makes them considerably less frightful than they could be. It’s far more interesting to have a villain with a few admirable qualities, or at least a ‘higher purpose’ that you can sympathise with without necessarily endorsing their actions to achieve it. In the same way a protagonist is more interesting and relatable if they have some negative traits that makes liking them a little harder than it might be otherwise.
A good example of the latter is the protagonist James Holden from ‘The Expanse’ series of science fiction novels (also a series on Amazon Plus). Holden is in some ways a monster whose actions arguably result in the needless deaths of thousands of people. Holden’s favourite quirk is to acquire sensitive information, then broadcast it round the solar system apparently heedless of the disruption it will cause and the innocent lives it will impact. He’s arrogant, spoiled, headstrong and, often, thoughtless. On one occasion he invites his crew to cast votes for who will captain their ship - a vote he wins - then he loses the next vote and sulks, and when he calls his third vote he takes a gun with him just in case anyone arrives at the ‘wrong’ opinion.
Holden sounds irredeemable, but his motives are always good. He broadcasts dangerous information is the belief that sunlight is the best disinfectant, which is a position that has some merit, and his taking a gun to the ship’s meeting was his clumsy attempt to preserve the life of the woman he loves. No-one can accuse Holden of acting wholly in his own self-interest. Ultimately he wants to make things better (though he often ignores the fact that the road to hell is paved with good intentions) and he won’t hesitate to risk his own life to help others. Holden is infuriating and getting mad at him is actually quite fun.
On the other side of the coin we have an out-and-out villain like Al Swearengen, the saloon owner and brothel keeper of HBO’s 'Deadwood'. Al is a thief and racketeer who sets up innocent travellers for robbery and slaughter for a cut of the profits, and feeds the bodies of his numerous victims to his neighbour's pigs. Al is very much a bad guy and even though we unearth enough of his background to appreciate how he’s become the man he is, this is not someone you’d ever want living next door to you. But despite all this Al does have some decent traits. He’s fiercely loyal to his crew and has an honest affection for many of them. In the show’s last season he’s driven to perform an unspeakable deed to protect the life of one of his (and our) favourites. It’s an action that his warped sense of compassion forces on him but he only carries it out once he finds every other avenue blocked to him. Despite the bloody resolution to Al's dilema, we can see past his brutality and feel pity for Al in his torment. He eventually becomes a man it's hard to hate.
The upshot? Unless your aiming for a dramatic twist, pick a side for your character and keep them there, but write them in shades of grey, not black and white.
For more on writing characters, check out The Writers' Guide.