Ants have a complex social structure. Case in point: some scientists used to think that worker ants are all females who control the queen (a simple egg-laying machine) and kill their brothers while still larvae.
It turns out the queen has more say than this: she controls the number of females and male eggs she lays.
But why does a colony’s sex ratio matter? A queen wants to propagate her line by producing another queen, which needs male drones to mate and produce a colony. Worker ants, on the other hand, have no use for males (which die after mating).
So, the queen and her daughters negotiate a rather violent solution: when she needs male drones, the queen will "overwhelm" the colony with male eggs. The female workers will kill many of their brothers, but they can’t kill them all! (Source)