It's what they do to naughty horses who don't behave (or some older ones with health issues).
Surprisingly (or horrific in hindsight), many of the great stallions barely avoided being gelded (Eclipse, St. Simon, and IIRC Halo too, to name a few). Imagine what the horse racing world (and Umamusume) would've looked like if they'd been gelded...