Michael D. Coogan, The Old Testament: A Literary and Historical Introduction to the Hebrew Scriptures, third edition (OUP, 2014), 123.
It is important to note that the Bible contains three different versions of the Decalogue. The first is in Exodus 20.2-17; in its present form, it has been edited by P; note especially the reference to Genesis 1’s account of creation in six days (Ex 20.11). The version found in Deuteronomy 5.6-21 is largely the same as that found in Exodus 20, although there are some differences, most notably in the motivation given for the sabbath (Deut. 5.15; compare Ex 20.11), and in the separation of the coveting of the neighbor’s wife and property into two separate commandments.
Yet another version of the Decalogue is found in Exodus 34, in the context of the episode of the golden calf….When he sees what has been going on, an angry Moses breaks the tablets that contained the text of the commandments, and so he is instructed by Yahweh to go back up the mountain to get a replacement copy. That replacement copy is explicitly identified as “the words of the covenant, the ten words” (Ex 34.28), but the text that precedes this identification, Exodus 34.10-26, differs significantly from the more familiar versions in Exodus 20 and Deuteronomy 5. Unlike these other two versions, which combine rules about worship with rules about human conduct, this version is almost entirely concerned with worship; for this reason, it has been called the “Ritual Decalogue.” It is difficult to enumerate exactly ten “words” in this passage, but that is clearly what the authors intended. Since readers knew what was on the first set of tablets, there was no need to repeat their content. Instead, the editors of the Pentateuch took advantage of a twist in the plot to incorporate another Decalogue tradition. The presence of three different versions of the Ten Commandments suggests that although the general tradition about them was very ancient, variants existed. For the editors of the Pentateuch, it was more important to preserve these variants than to harmonize them.