Castration was used in the Middle Ages as a 'cure' for hernia, epilepsy, and leprosy.

Castration was used in the Middle Ages as a “cure” for hernia, epilepsy, and leprosy.

Source