How was such a useful taboo developed earlier than Gregor Mendel (20 July 1822 – 6 January 1884)?
=============================================================================
This happened in many societies, but not in all of them.\
The Pharoahs in Egypt were often the children of brother-sister marriages. Cleopatra Ptolomeus was the eleventh generation descendant of Alexander the Great's general Ptolemy. Hawaiian royalty was also incestuous. This was common in much of Polynesia. So long as there is not a serious genetic defect in the bloodline, this is not necessarily an unhealthy thing.
If you check the bloodlines of AKC winning dogs and racehorses, you will find a LOT of incest.
As I recall, incest was not permitted as readily to the non royal members of these societies.
Upon occasion, the king's heirs were not really the genetic descendants of the king. In one of Goya's famous paintings, the princes and princesses looked far more like Prime Minister Godoy than they did like the king, Carlos IV. The king, they say loved the portrait, So did the queen, who looks like a harpy.
I am not in favor of incest, but making it a taboo as well as making it compulsory are both worse than ideal.