People aren't saying be mean to a girl, in fact you can be nice. But what most people are referring to when they talk about "nice guys" are desperate guys. These guys are needy and clingy and almost immediately demonstrate low value to her.
It's possible to be nice and still get laid like a rock star. But that's not the kind of nice guy that people are usually referring to here.
And you can actually be ****y and funny and very nice at the same time. Remember, you're busting her balls in a friendly way and keeping her laughing and interested in you while at the same time doing nice things for her. Like you could constantly be busting her balls and getting her laughing but at the same time holding doors open for her, taking her coat etc.