He knows them because he works with them: nurses who kill to save their art pieces from going down in value; internists who kill significant others to prevent them confessing stuff to others; doctors who kill to protect their legacies--or make money.
Even Alan Rachins shows up as a bad guy!
The reason Sloan's kindliness is so excellent is that unlike many detectives on television, Sloan doesn't automatically, instinctively know that a particular person is a bad guy. Every now and again, he has less than fond feelings for potential bad guys, but most of the time, he is willing to give people a chance. He is as surprised as everyone when they go bad.
A lot of relationships on Diagnosis Murder have a vaguely sociopathic quality--that is, the boyfriend or girlfriend is so self-interested and conniving, they easily fool others with their charm. On the one hand, these characterizations may seem like a way to excuse Sloan's "blindness." However, there is another possibility, namely--
People are good until they aren't.
Mark Sloan, played by the excellent Dick Van Dyke, treats nurses and internists and doctors as decent human beings because they should be; they can be. If they then do evil things and make evil choices, that is on them, not on the genial doctor who gave them a chance.
It is a remarkably advanced moral perspective that is quite consistent throughout the show. Fate does not make criminals, even criminals who have suffered. Even criminals who were pushed too far.
"I didn't have a choice," one murderer tells Sloan.
Sloan treats everyone with respect because until they kill, they are in fact deserving of respect. They aren't inherently bad due to a future action (or a label or their group identity). Badness is contingent on behavior.