@rye Not sure about good girls. But bad guys are often liked because women have shit self-esteem, and being treated like shit is familiar to them... they don't think they deserve better. That is one part of it.
Another possibility is that the traits bad guys tend to exhibit are attractive, and so even if they don't want to be treated like shit... they will admire those traits, or perhaps think that he will be changed by them. It's quite a fantasy power play. You will see this trope in stories where the bad guy gets to know the girl, and he will be changed because of that. He won't want to sleep around, for example. But the seeming confidence that bad guys exhibit can be attractive, how opinions don't impact them as much. How a girl is the one that gets to see his soft and vulnerable side, she becomes the exception. How he will be protective of her, and shower her in affection. Bad guy is basically wounded guy... women can be suckers for that.