Marriage of close blood relatives at the beginning of creation
Question

                If all of humanity are the descendants of Adam, does this mean that marriage to close blood relatives (mahrams) was permissible at the beginning of creation? Then when did it become prohibited?
Praise be to Allah.Necessity dictated 
      that the children of Adam (peace be upon him) had to marry one another in 
      order to produce offspring and populate the Earth. 
In some reports it 
    says that no son was born to Adam (peace be upon him) but a girl was also 
    born with him, so the boy born from this pregnancy married a girl from 
    another pregnancy, and the girl born from this pregnancy married a boy from 
    another pregnancy; it was forbidden for the boy and girl from the same 
    pregnancy (i.e., fraternal twins) to marry one another. 
This is mentioned in 
    reports narrated by Ibn Jareer at-Tabari in his Tafseer (10/205-207) 
    from Ibn ‘Abbaas and Ibn Mas‘ood (may Allah be pleased with them). 
However, we do not 
    find in the Holy Qur’an or the Prophet’s Sunnah any mention of the 
    historical development of stages in the rulings on prohibitions on marriage 
    to close relatives (mahrams) or on the degree of blood relationship that 
    makes a person a mahram (and thus prohibited in marriage). But what we do 
    find in the Holy Qur’an is the prohibition on marriage to mahrams, where 
    far-reaching degrees of kinship are mentioned. It includes marriage to one’s 
    brother’s daughter, one’s sister’s daughter, one’s father’s wife and even 
    includes mahrams because of breastfeeding. That is the verse in which Allah, 
    they He be glorified and exalted, says (interpretation of the meaning):
“Forbidden to you 
    (for marriage) are: your mothers, your daughters, your sisters, your fathers 
    sisters, your mothers sisters, your brothers daughters, your sisters 
    daughters, your foster mother who gave you suck, your foster milk suckling 
    sisters, your wives mothers, your step daughters under your guardianship, 
    born of your wives to whom you have gone in - but there is no sin on you if 
    you have not gone in them (to marry their daughters), - the wives of your 
    sons who (spring) from your own loins, and two sisters in wedlock at the 
    same time, except for what has already passed; verily, Allah is 
    OftForgiving, Most Merciful”
[an-Nisa’ 4:23]. 
Anyone who speculates 
    about the historical development of the rulings on marriage to close 
    relatives, and the details of that, is only speculating on matters of 
    conjecture about events in history and the laws of the Messengers, basing 
    it, for the most part, on reports from the People of the Book. This – as is 
    obvious – is likely to be wrong and based on imagination, and subject to 
    addition and subtraction, as narrated by the historians in the story of Adam 
    (peace be upon him) and by some of the mufassireen in their commentary on 
    the verse in which Allah, may He be exalted, says (interpretation of the 
    meaning):
“And (O Muhammad) 
    recite to them (the Jews) the story of the two sons of Adam (Habil (Abel) 
    and Qabil (Cain)) in truth; when each offered a sacrifice (to Allah), it was 
    accepted from the one but not from the other. The latter said to the former: 
    ‘I will surely kill you.’ The former said: ‘Verily, Allah accepts only from 
    those who are Al-Muttaqoon (the pious)’”
[al-Maa’idah 5:27]. 
Some contemporary 
    writers have also looked for such information in the Torah and Gospel which 
    have been distorted, and in some of the history books of earlier nations. 
There is no benefit 
    in knowing when marriage to close relatives was forbidden in earlier laws; 
    if that were the case, Allah, may He be exalted, would have mentioned it, or 
    His Messenger (blessing and peace of Allah be upon him) would have mentioned 
    it, for he did not omit anything that was beneficial or useful but he told 
    us of it. What should concern us is the fact that Allah, may He be exalted, 
    has definitively forbidden marriage to close relatives (mahrams) in His 
    Book, and this is also indicated by the Prophet’s Sunnah and scholarly 
    consensus. 
And Allah knows best.