Evolution is never a causal relationship even though school books often teach it that way. It's never that a feature evolves with an intent to make a change. It's always random mutation that then ends up being a positive thing and those animals then reproduce more.
So, in this case those people who developed the mutation ended up having more sex and thus reproducing more. The ones who didn't have it either had reproduced with those who did and thus their descendants ended up with it, or they didn't reproduce enough and died off.
That's how all evolution works in reality. The trait either makes it easier to survive, makes reproduction easier (or more survivable), or it makes the mate more appealing and thus more want to mate with the people with that trait than without.
Basically everything else is either connected to one of those traits, or there were other external factors that made that group more able to survive and reproduce and thus the trait had no real reason not to exist and just was random chance.