I came upon this question far too many times on the Internet (especially 9gag) and it seems like many young men are wondering WHY would girls do that? It seems so illogical and masochistic.
As a woman, I believe at one point in our life, we experienced such crazy attraction to bad boys. It's like ... inevitable. Of course, there will be women who disagree, I totally understand from their POV as well. What I am saying might just apply to some women. You shouldn't take my words too seriously. I'm just offering my own understanding on this topic.
So why would girls be attracted to bad boys?
2) Girls Love Glory
For some girls, dating a bad boy can be seen as a challenge. Why would the school's #1 sexy hotshot wants to date you? You gotta have something the guy wants. So what's it is? People will start gossiping and create lots of noise. Some girls like to be in the spotlight. You can't blame them. Everyone wants to be famous. Some just do it differently. Also, girls like to flirt with danger. They think they can be the special one who can save the bad boys from their secret darkness. It's like... a fantasy girls develop. "He treats everyone like crap but not me. I am his special person." That's probably why Twilight and 50 Shades of Grey are popular among the female population. The main heroine is the only one the handsome protagonist ever wants. Bella (and whatever-her-name-is... Anastasia?) eventually helps Edward (or Christian) out of his misery. Big whoop! Girls go gaga over that. I myself am not easily moved by such cheesy plot and cliche characters but many girls are. They lack exposure to literature. Sadly. Anyway. Next!
One of the main features bad boys have is that they are very good at charming people. They whisper sweet-nothing to your ears and turn you into goo. They are the Don Juan. Once they get what they want, they dump the girls. It's obvious. Bad boys have their reputation to upkeep. They don't want people to think they are "attached". No, that would sound horrible. Almost too horrible. That's why they move constantly from girls to girls like changing clothes. So from a good boy's perspective, bad boys are the ultimate douchebags. They get the girls but they don't give a damn.
Answer: Some girls like good guys but most girls will be like "but you are soooo booooring. I'm young and I want to have fun! You are not fun at all! Why would I date you when I can date Don Juan who is so interesting?" Now, I am not saying you must all turn into bad boys the next day. From experience, I know plenty of good guys who are super interesting. They get their girls later on... why later on? Why not when they are in high school or something. Why later? Next point says it all.
4) Natural Selection
Girls like capable men. It's instinct. Even in animals, females only mate with powerful males. If a male lion loses to another male lion, the winner lion kills all the cubs. That sucks. Imagine you must witness some douchebags kill your kids because your useless husband can't put on a fight. Same goes for humans. In prehistoric period, you need to have an independent man to survive. The guys had to go build a hut, hunt wild animals (Can you imagine a fat bum chasing after a deer?) and go to fight rival clans. They want men who have the highest survival rate. Who wants to mate with a loser who fails in everything and leave you all the burdens? The same apply for men about women. You want to date sexy women who you subconsciously relate to: She can birth me good children. The bigger their boobs or wider their curves are, the more you lust after them. Now that you kind of understand, back to bad boys. You probably realize that in school, bad boys are pretty popular. Why? Natural selection. Nowadays, men don't have to prove themselves as much as before so...? So for young girls, they associate bad boys as someone independent and worthy. Bad boys just seem so wild, strong and confident that girls just can't help but go weak in their knees.
Girls are just attracted to men who they deem worthy. Once they mature, they realize swag and bad boy stunts won't get them good reputation. Bad boys won't give them big cash. Bad boys can't provide them the ideal life they wanted so badly. What now? The answer is they turn to the good boys who used to be very nerdy and boring. Good boys studied a lot and so they become successful. Being successful, it means lots of cash inflow. You hear it so often. Women (not girls anymore) love money. They do anything to have money. Why? Because now that we don't need to go chase deer and build our own huts. Money does all that for us. So obviously, women want money. It sort of compensates for the lack of manliness in men these days. Before: strong husband = high survival rate. Now, having lots of money = better survival rate. The need for capable men suddenly didn't sound so necessary anymore (now that women too work).
If you really want to get the girls... be assertive. Don't be a pushover. It's not attractive at all. My advice is: be good boys. Eventually, women will come to you. They will realize they want men who treat them fairly (something bad boys might lack). In the end, people just want to be loved. Even bad boys. Even your grandma, your dogs and hamsters.