They don't. That's a myth. Girls and women "with issues" may prefer "bad boys", but well adjusted girls and women don't. Plain and simple.
A lot of nice guys like to believe it's because they aren't "bad boys" they can't find a girlfriend (and a beautiful one). Some guys may not be good at recognizing the "something off factor" in beautiful girls/women who gravitate toward "bad boys", so they jump to the conclusion that "all" beautiful girls/women are attracted to that and don't know how to find beautiful potential dates that don't "have issues".
Guys are known for "having ego". For a lot of them, it's a lot less painful to just assume it's because they're nice that they can't attract a beautiful girlfriend; when, really, there's something else about what they are or do that makes meeting "Ms Perfect" more challenging than it needs to be. Also, a lot of guys are too young to screen out the "have-issues" girls/women before then considering whether they find them beautiful or not.
There's incentive for "bad boys" (who often don't recognize a girl/woman "with issues" or else don't care about that), and for "nice guys" (who have trouble meeting the girlfriend they'd like to meet) to believe, and pass around, this myth. "Bad boys" are happy with their "issues" girlfriends and lifestyle, and don't care about healthy relationships anyway. Nice guys get away without facing that there may be something else that's making meeting the right person difficult for them. It doesn't help that women who, for some reason, are attracted to "bad boys" help perpetuate the myth (because they don't recognize that they, themselves, "have issues"; even if their "issue" is only immaturity).