He's seen as confident, cool, a mystery, a challenge, unpredictable/exciting.
Some women go through a "bad boy" phase usually during their youth. (teens- late 20s) It's as if they're living by the following motto:
"We ignore those who adore us and adore those who ignore us."
During this phase you could stick such a woman in a room with five guys and have four them drop to their knees extending their heart out towards her while the 5th guy sits in a corner sipping on a cocktail acting as is she does not exist.
That will be the guy she wants to get to know!
And if it turns out other women are into him that just raises his stock even higher. She feels the need to prove to herself that she can win his heart, gain his attention and affection. Competition just makes her try all the more harder to (win) him over.
Another factor is many "bad boys" are admired or feared by other guys. Many women are drawn towards men who are viewed as powerful or leaders. The captain of the football/basketball team, president of ...etc Essentially if (he) is in "the spotlight" and she is with him then (she) is also in the spotlight.
Last but not least Hollywood movies and romance novels have always depicted true love as being a "roller coaster" filled with drama, pain, and heartache before eventually leading to "happily ever after".
When "Mr. Nice Guy" shows up he's not the character that's been portrayed in the hot romance storyline. He's always on time, bends over backwards to make sure she is happy, he's polite, considerate, dependable, trustworthy, emotionally and affectionately generous.
Women in a "bad boy" phase will say he's "too nice" or they fear breaking his heart so they drop kick him into the "friend zone".
Silently he'll sit on the sidelines providing an ear to listen to and shoulder to cry on as she tells him stories about her (no good) "bad boy" who mistreats her but she can't imagine life without.
Eventually after several broken hearts these women decide to try a different "type". It's a practical decision not an emotional one.
Years ago author Lori Gottlieb wrote a book titled:
"Marry Him: The Case for. Settling for Mr. Good Enough"
She espouses women let go of the fantasy of the knight in shinning armor , the handsome rich dashing prince, and the "bad boy" who makes their heart "skip a beat" but instead take a hard look at men who are nice, good, decent, loving, trustworthy, and reliable.
I bet these women still fantasize about "bad boys".