Eunuchs in China had been known to usurp power in many eras of Chinese history, most notably in the Later Han, late Tang and late Ming Dynasty. There are similar recorded Middle Eastern events.
In ancient times, castration often involved the total removal of all the male genitalia. This involved great danger of death due to bleeding or infection and, in some states, such as the Byzantine Empire, was seen as the same as a death sentence. Removal of only the testicles had much less risk.