A mamzer may not enter the congregation of Hashem… (Deuteronomy 23:3)
There is so much that is commonly misunderstood about the mamzer, a word that is used as an epithet and popularly translated as “bastard.” For starters, the implication of “bastard” is one born out of wedlock, but such a person would not be a mamzer and would not be subject to the marriage limitations described in this mitzvah. Rather, a mamzer is the product of an incestuous or adulterous relationship. The mamzer may not join the general marriage pool but, as we said regarding the eunuch in the previous mitzvah, he still has options.
The obvious question is why the mamzer should be penalized for something his parents did. The nature of that is similar to asking why the offspring of two very close relatives should be “punished” with genetic defects. The reality is that some relationships create serious defects, some genetic and others spiritual. Just as people might screen themselves to avoid perpetuating Tay-Sachs and other genetic defects, they must strive to avoid polluting the gene pool with the taint of incestuous and adulterous unions.
While the mamzer could not join the general marriage pool, there were some he could marry. Obvioiusly, a male mamzer and a female mamzer could marry each other. A mamzer could also marry a convert. (A mamzer can even marry the offspring of two converts, even though that person was born Jewish! See Talmud Kiddushin 75a.) When there was still indentured servitude, there was actually a way to purify the mamzer’s lineage in a single step: the mamzer could marry a maidservant. The offspring of this union could be freed and would then be a full-fledged Jew free of the taint of the incestuous relationship.
This prohibition applies in all times and places. It is discussed in the Talmud in the tractates of Yevamos (49a-b, 75b) and Kiddushin (66b-70a, then scattered throughout the chapter through page 78b). It is codified in the Shulchan Aruch in Ever Ha’Ezer 4. This mitzvah is #354 of the 365 negative mitzvos in the Rambam’s Sefer HaMitzvos and #137 of the 194 negative mitzvos that can be observed today as listed in the Sefer HaMitzvos HaKatzar of the Chofetz Chaim.