The Mishna (66b) offers guidelines for determining the family and legal status of a child. If a child is born from a union of two people who can marry each other, the child’s status follows the father (e.g. if he is a kohen or a levi). If the relationship that produced the child is a forbidden relationship, sometimes the child is defined by the relationship itself (e.g. a kohen who marries a divorcee, where the child is a halal – he is not a kohen and cannot marry into a priestly family), sometimes it follows the status of the mother (e.g. a shifha kena’anit – a non-Jewish maidservant’s child would be a slave), and sometimes the child is a mamzer.
The case of a mamzer, according to the Mishna occurs when a normal Jewish woman, who could have married any Jewish person, has sexual relations with one of the people forbidden by the Torah in parashat arayot (see Vayikra chapter 18) – i.e. incestuous relationships. A mamzer is not allowed to marry into the normative Jewish community.
Our Gemara asks for a source for the fact that incestuous relationships are the ones that create the status of mamzerut, and launches into a lengthy search to prove this halakha based on pesukim. Tosafot ask why the Gemara needs to find a source for the connection between arayot and mamzerut, arguing that it seems to be obvious and self-explanatory that forbidden sexual relationships that do not even allow for marriage to take place – as opposed to relationships that are forbidden, but if they are done, halakha recognizes their existence (e.g. a kohen who marries a divorcee) – would produce offspring who are mamzerim.
Tosafot answer that this Gemara follows the opinion of Rabbi Yehoshua who believes that only some of the arayot will produce mamzerim. He distinguishes between those sexual relationships that are capital crimes, punished by the courts and those whose punishment is karet – a heavenly punishment, even though he agrees that halakha will not recognize marriages in either of these kinds of cases.