This verse has a beautiful chiastic structure:
This is the history
A of the heavens
B and the earth
C when they were created
C* in the day the LORD God made
B* the earth
A* and the heavens.
This chiastic structure stresses the literary unity of this verse. The first half looks back on Genesis 1 (in accordance with the toledoth expression): our attention is directed from the whole of the cosmos to the earth. In the second half our attention is fixed on the earth, now in the first position. The following story will tell us what arises on earth from the creation of heaven and earth. Since heaven
usually comes first in the expression heaven and earth,
the reversal in the second half emphasizes our attention on the earth. Thus, the earth is at the centre of our attention (Ezekiel 8:3; Zechariah 5:9; 1 Chronicles 21:16; Psalm 148:13).
4 These are the generations of the heavens and the earth when they were created, in the day that the LORD God made the earth and the heavens.