Hatred, as best as I can define it, is a hardening of the heart fuelled by anger against perceived enemies. Does anything good ever come from anger and hatred? Hatred of enemies sounds like a good idea, but as Nietzsche put it, be careful of turning into a monster yourself.
Like all basic emotions, hatred is surely an evolutionary adaptation, so it is clearly good for something. In particular, evolutionary theory suggests that genes coding for "never hate" and genes coding for "always hate" probably tend to die out pretty quickly, while more nuanced "hate under these circumstances" genes tend to fare much better. But this is an oversimplification, of course, for example due to pleiotropy.
If you want a more philosophical answer, I suggest editing the question to ask "is hatred ever justified?" or some variant thereof.
Briefly, my thoughts about this modified question:
- I don't think that hating a particular ethnicity or gender is ever justified.
- Nonetheless, certain groups probably have the property that hating their members is justifiable, for example you could build a pretty convincing philosophical argument that it is morally justifiable to hate the group that we might call "emotionally cold people incapable of empathy whom get a buzz out of hurting or otherwise dominating others." Although to be honest, I think it would be exhausting to carry such strong emotions; much better to simply dislike this group, and to simply not give a darn about their well-being; after all, they don't give a darn about yours.
- It may be justifiable to hate certain ideologies, such as white supremacy, especially if those ideologies themselves promote hate or otherwise unfairly dehumanise certain groups of people. On the other hand, it could be argued that it makes more sense to carefully and thoughtfully argue against ideologies that promote hate, rather than to hate those ideologies ourselves. Once again, let me just point out that hating an ideology sounds pretty exhausting, and that there are much better ways to work for change in the world.