"Can't think why it would become taboo before people knew about genetics as without that bit of knowledge it seems a pointless rule. That's why I have assumed it was based on religion."
People wouldn't have known why but they could see the effects that it had both on people and on animals. A fair few religious laws are actually codifications of things that just made sense but that they couldn't actually explain. People wanted explanations, religion then gave them.
There's a famous study somewhere about some farmers. They had a complex religious system that explained what they should plant for each year otherwise the God(s) would be angry. Modern farmers turned up and advised the locals to tinker with the system as they knew best and the current system was just based on religious "nonsense". The crops failed.
As it turned out the religious system actually described pretty much a perfect crop rotation system for that ecosystem. The ancestors of the people had probably hit upon it without knowing about the nutrient science behind it. People like explanations so it was because the God(s) wanted it that way, people kept doing it, the crops flourished.
Likewise ancient people saw the defects that inbreeding would cause, decided to reject it, couldn't explain why, so just said that the Gods didn't approve of such a union.