The theory as I just now read it is that "...Cain’s wife would most logically be one of his sisters or a close female relative from among Adam and Eve’s progeny. In the earliest generations, such marriage was necessary to fulfill humanity’s command to “be fruitful and multiply.” The theory continues that at such an early point in Earth's history, such intermarriage was the only way for the human race to expand. There are further theories that it wasn't wasn't until much later that "as mutations in the gene pool accrued," it became necessary for God to command that marrying close relatives be avoided (Leviticus 18-20). The laws handed down in Leviticus were written after Exodus from Egypt and during the wandering in the desert. My Quest Bible puts the date Leviticus was written at 1440BC.
Apparently, this topic has come up before. It never really occurred to me. I find it interesting that what we know to be necessary variation in the genes of parents is referred to as "impurities in the gene pool" that did not exist early on. As an aside (and to provide a frame of reference to the state of generations from that point forward), I read some time ago that there is enough genetic variation between first cousins that the risk of their offspring having birth defects is roughly the same as a woman giving birth at age 40. If I recall correctly, the risk is under 5%, perhaps as low as 3%. It struck me as being much lower than I would have expected.