…do not do this in your land. (Leviticus 22:24)
After specifying that an animal whose testicles are mutilated may not be offered, the Torah adds, “Oh, yeah, by the way – don’t do that!” The fact that the Torah says “in your land” does not mean to limit this prohibition to Israel. Rather, it means not to permit it to be done to man or beast among the Jewish people (see Talmud Shabbos 110b).
We may not hire non-Jews to castrate animals for us but we may purchase already-castrated animals from them and eat them. It is particularly reprehensible for a Jew to hint to a non-Jew that he wants a certain animal gelded. If he does this, he is not permitted to keep the animal; he is compelled to sell it against his will as a penalty (Talmud Baba Metzia 90a-b).
The reason for this mitzvah is obvious. God created the world and all the species in it, and it is His desire for these species to procreate and fill the world with their progeny. For a person to castrate an animal demonstrates a blatant desire to go against God’s plan. Doing this is tantamount to saying that he hates God’s world and wishes to hasten its end.
Sterilizing a female does not fall under this prohibition as the obligation to procreate is only incumbent upon the male.
This mitzvah applies to both men and women in all times and places. It is discussed in the Talmud in the tractates of Shabbos (110b-111a) and Baba Metzia (90b). It is codified in the Shulchan Aruch in Even Ha’Ezer 5. This mitzvah is #361 of the 365 negative mitzvos in the Rambam’s Sefer HaMitzvos and #143 of the 194 negative mitzvos that can be observed today in the Chofetz Chaim’s Sefer HaMitzvos HaKatzar.