שֵׁשֶׁת יָמִים תַּעֲבֹד, וּבַיּוֹם הַשְּׁבִיעִי תִּשְׁבֹּת; בֶּחָרִישׁ וּבַקָּצִיר, תִּשְׁבֹּת
and in Exodus 23:12:שֵׁשֶׁת יָמִים תַּעֲשֶׂה מַעֲשֶׂיךָ, וּבַיּוֹם הַשְּׁבִיעִי תִּשְׁבֹּת--לְמַעַן יָנוּחַ, שׁוֹרְךָ וַחֲמֹרֶךָ, וְיִנָּפֵשׁ בֶּן-אֲמָתְךָ, וְהַגֵּר
Perhaps the people were lax about Shabbat observance, and they needed, in the eyes of the priestly editor, an additional reason for keeping the Shabbat. If the people had to have one day of rest after working for six days, is it not logical that HaShem did the same thing in Creation?After it was added to the account of Creation, other instances of Sheshet Yamim (Shemot 20:9, 31:17) were added to passages in the Torah, to suggest that just like HaShem worked six days and rested on the seventh day, so should the Jew. The priestly editor likely had great success, the Torah became much more convincing.
But, really, prior to the priestly editor, the truth was opposite. The priestly editor, hopefully with the best of intentions, added a layer of Sheker to the Torah.
Interestingly, davka the verses by the priestly editor are said in the Kiddushim for Shabbat. On Shabbat eve we recite what is written on the seventh day of Creation. On the Shabbat day we (not if you follow the GR"A) recite davka the problematic verses Shemot 20:9 and Shemot 31:17. Download from here my repair of the Kiddushim, which involves the above two verses on the Shabbat day and the reconstruction of the beginning of Torah on Shabbat eve. Of course, we have in mind this view of the Shabbat: Rather than emulating the resting of HaShem, we contemplate about what HaShem does in the world.