There’s 1000 videos on YouTube and thousands of articles on the internet by social commentators and evolutionary psychologists and biologists discussing this.
Basically for all the reasons everyone has already said upthread. Bad boys are perceived to be more confident, assertive, not averse to risk, sexually confident, unpredictable, always back themselves, know what they want and get it, decisive, a maverick, secure in themselves, not desperate, a heartbreaker, an overall alpha male etc... it can be a very intoxicating combination of factors to a woman!
This bad boy archetype is then solidified and reinforced in romance fiction, films, books, TV and especially social dating situations in every single era (The age old nice guy loses the girl he likes to the exciting, thrilling bad boy but then she finally realises he’s a melon head and realises the nice guy was right for her all along).
It’s the same old story every generation!
I’ve dated both types of guys (mainly nice) but I’ve realised that both bad boys and nice boys have the capacity to break your heart!