The castration does two things:
One: It ensures that they won't be able to violate the harem they're supposed to be guarding, and
Two: It means that, despite the fact that they're still subject to the buildup of hormones (especially, you know, spending all day guarding a harem), they're left with no means of releasing the tension. Thus you get very, very angry guards.
Everyone wins! Except intruders, but they're supposed to lose. And the Eunuchs kinda lose to, but their opinions don't matter. And I dunno if you could necessarily call being confined to a singe room for the rest of your adult life "winning" either. But their opinions count for only slightly more then the eunuchs'.
So the only person who really wins is the dude who owns the harem. But that's what the system is for.