Sometimes this phrase gets a bad rap, and maybe, at times, rightfully so when it is cliché or excusatory for unkind words and actions. But, interestingly, in Mere Christianity, none other than C.S. Lewis gives a defense/explanation of it. I find the way he slices it helpful.
[A]pparently I am allowed to loathe and hate some of the things my enemies do. Now that I come to think of it, I remember Christian teachers telling me long ago that I must hate a bad man’s actions, but not hate the bad man: or, as they would say, hate the sin but not the sinner.
For a long time I used to think this a silly, straw-splitting distinction: how could you hate what a man did and not hate the man? But years later it occurred to me that there was one man to whom I had been doing this all my life-namely myself. However much I might dislike my own cowardice or conceit or greed, I went on loving myself. There had never been the slightest difficulty about it. In fact the very reason why I hated the things was that I loved the man. Just because I loved myself, I was sorry to find that I was the sort of man who did those things. Consequently, Christianity does not want us to reduce by one atom the hatred we feel for cruelty and treachery. We ought to hate them. Not one word of what we have said about them needs to be unsaid. But it does want us to hate them in the same way in which we hate things in ourselves: being sorry that the man should have done such things, and hoping, if it is anyway possible, that somehow, sometime, somewhere, he can be cured and made human again.
C.S. Lewis, Mere Christianity, book 3, chapter 7, paragraph 6-7.