It does make one wonder about why anyone with enough common sense would prefer to hang out with "bad boy" instead of someone with good credentials. Here are a few reasons why girls like bad boys:
Adventure
Good guys play it safe. Whether it is any physical activity or taking an important decision, they are always hesitant. Bad boys, on the other hand, are primarily known for the sense of adventure they carry on their sleeves. They are not scared of taking risks and give girls a sense of adventure that they want to experience. Women want to have a feeling of power that these guys readily provide.
Living life
Bad boys are seen as living life as it is meant to be lived. It is necessary here to define that bad boys do not mean criminals or anti-social elements but guys who lead happy lives by breaking norms rather than breaking laws (although the latter has its share of allure and fan following too). Bad boys, because of their propensity to leading the good life, are always clued in to the latest happenings and live with objects that good guys think twice before investing in. Mean bikes and jailbreaked Apple devices for example.
Air of mystery
There is something utterly predictable about a good guy once you've known him for a while. His tastes do not change simply because the year has. A bad guy, however, doesn't live by scruples. His main aim is to lead a happy life today. He is not bothered about his past nor worried about his future. The here and now and how that can be made better is all that matters to him. This lends an air of mystery to him and his actions because you can never predict what catches his fancy and how he will attain it from one day to the next.
Good with girls
It is a known fact that bad guys know how to score with girls. It is one of the reasons why they are tagged as bad guys in the first place! Such a group knows how to woo a woman and make her feel special. They can talk to her and when they feel like it, also talk back to her, giving the girls an opportunity to be aggressive as well. Good guys avoid conflict at all costs, leaving girls with no window to vent their frustration.
It's biological
Blame it on your forefathers, but the fact is that women are wired to seek out the most adventurous guy in any group. It goes back to survival of the fittest and other procreational jazz, but the short story is that, a woman will always prefer a man who is seen as taking initiative (with variable risk) over a steady guy waiting for something to happen to his life. Accept it: the only way of scoring with girls is to join this breed of bad boys and strike rich. Like it is said, if you can't beat them, join them.
In spite of all these points, it doesn't mean that girls don't like good guys at all. There are women who love the company of good guys and would pick them over the 'bad boys' any given day.