GeneticsThanks to the discovery of the laws of genetics a fairly modern part of the taboo against cousin marriage is the perception that this form of inbreeding results in heightened risk of offspring with genetic disorders like hemophilia or albinism. A study in Western Australia discovered that while the risk of a serious defect does rise slightly, the change isn't that dramatic (i.e. a 4% risk for first-cousin parents instead of a 2% risk for unrelated parents—roughly equivalent to the risk of birth defects in children conceived by women age 35 and older as compared to children conceived by women under 35) Please note, however, these statistics apply only to first cousins: any couples more distantly related are likely to be as genetically dissimilar as randomly paired individuals from the general population (how many of your third cousins do you even know?).note And the first-cousin marriages studied were one-time occurrences, those statistics don't cover an entire family tree doing it for generations like has been seen in certain aristocratic populations—repeated, exclusive endogamous marriage is likely to have more serious genetic consequences. And if there's known to be a serious hereditary condition in the shared part of the family tree, it's obviously a bad idea.
CultureSome cultures distinguish between parallel cousins—the children of siblings of the same gender (i.e one's mother's sister's kid or father's brother's kid)—and cross cousins—the children of siblings of the opposite gender (one's mother's brother's kid or father's sister's kid). Cultures in which a parallel cousin is taboo often regard the cross cousin as the best possible choice of a spouse, since the marriage will strengthen bonds among members of the bloodline and ensure that property remains in the family.
ReligionMost of the origins of the cousin marriage taboo are not inherently religious; the ancient Hebrew patriarchs demonstrably had no problem with cousin marriage at all (Isaac married Rebekah, his first cousin once removed). The largest Christian denomination, the Catholic Church, allows even first cousins to marry with special dispensation. First-cousin marriage is perfectly fine under Islamic law and some Middle Eastern and Central Asian cultures actively encourage it. Hinduism, Buddhism, Confucianism, and Asian animist traditions have little to say against cousin marriages either.
HistoryOne culture in which clan endogamy was primarily tabooed was medieval Europe; this prohibition extended as far as third cousins and included in-laws. In a chronically violent culture that put a far higher value on tribal and dynastic bonds than we do today, this was much more about trying to mitigate warfare by extending people's social networks than preventing inbreeding. This led to royal or noble families seeking to end blood feuds by marriage alliances often needing dispensation from the Church to marry—as, for instance, Henry VII and Elizabeth of York at the end of the Wars of the Roses. (Coincidentally, it was Henry VII's son Henry VIII who put an end to this in England by breaking from the Catholic Church: The Church of England notably omitted first cousins when listing which relatives were covered by incest prohibitions.)
This was also the case in China, in a historical period analogous to that of feudal Europe; nobles were explicitly banned from marrying any person that could trace their paternal lineage to the same historical tribe (effectively, anyone with the same family name). This was then extended to all social classes after the unification of the Chinese empire; people bearing the same surname were forbidden to marry even if they were not related at all. However, cousins with different surnames were allowed, and in many cases encouraged, to be paired together to strengthen the alliance between two clans during said period. Linguistic remnants of this tradition may still be found in some areas in Southern China, where the form of address used for one's mother- and father-in-law may also be used to address one's uncle and aunt.