I'm currently studying genetic disorders, and a friend of mine asked the above question. I know it's still a big cultural divider today, but how, and more importantly WHY, did ancient cultures hold their views on inbreeding?
The magic legal-history words you're looking for are "consanguinity" (degree of relationship by blood).
The degrees of consanguinity and affinity which are allowed have drifted and changed over time, however there is a long-term consensus around a consanguinity line at 4 (allowing first-cousin marriage but no closer).
In 1775 Samuel Halifax notes that in comparison to ancient Roman civil law, the English law of the time was more permissive. For example, marriage of first cousins was at times denied by the Romans around the time of Emperor Justinian (6th c. AD), but was then allowed by the English crown.
In 1215 the Fourth Lateran Council set the limits of affinity at 1 and consanguinity at 4 (canon 50) after they had previously been set much higher (meaning, more difficult to find a legitimate spouse).
Modern law (for example California) also sets the consanguinity line at 4.
As to the why, I'm not entirely certain, but hopefully this can get you started.
Primates do not inbreed. For example, female gorillas leave their group to avoid breeding with the alpha (which most likely would be their father). This would indicate that inbreeding avoidance probably occurred before human civilization began. The cost of having a defective offspring is just not worth the risk.