A man with crushed testes or a severed organ may not enter the congregation of Hashem. (Deuteronomy 23:2)
A man who was born with normal reproductive organs but who lost them was not permitted to join the general marriage pool.
The reason for this is to serve as a disincentive to castration. While this may seem the kind of thing that shouldn’t need any additional disincentive, at some points in history, castration was in fashion. This was the case with the eunuchs who guarded a sultan’s harem and it was the case with the castrati singers of the Renaissance and Baroque periods. But, as we discussed in Mitzvah #291, we’re not allowed to castrate animals–we’re certainly not permitted to castrate human beings! Hopefully, this prohibition gave people considering such a radical procedure one more thing to think about.
Of course, not everyone who lost his genitals did so intentionally. Isn’t it unfair to bar those who suffered horrible accidents from marrying? Well, they’re not technically barred from marriage. In Judaism, there are a number of marriage circles that overlap at various points. Someone in Circle A might be permitted to marry into Circles B and C but not D, or vice versa. So, while a castrated man could not marry into the general marriage pool, there were circles in which he could marry, such as converts.
This prohibition applies in all times and places. It is discussed in the Talmud in tractate Yevamos (70a, 75a-76b). It is codified in the Shulchan Aruch in Ever Ha’Ezer 5. This mitzvah is #360 of the 365 negative mitzvos in the Rambam’s Sefer HaMitzvos and #136 of the 194 negative mitzvos that can be observed today as listed in the Chofetz Chaim’s Sefer HaMitzvos HaKatzar.