Common theories from academicians says that this is an evidence that Moses who is the major author of the Old Testament, used two different materials as a source for his writing. I remember reading this when I was still an undergrad in UP Diliman. In the religious section of the main library was volumes of biblical commentary. And of those that I have read from there always have a reference on the two distinct names of God.
Back then I have not given much attention to that fact, but today I learned about the importance of that detail. In the book Hard Sayings of the Bible (Kaiser and others, 1996) it was described that there is a very precise rule on how the Bible uses names Elohim (God) and YHWH (LORD). This is amazingly illustrated in Ps 19:
Psalm 19 (New American Standard Bible)
Psalm 19
The Works and the Word of God.
For the choir director. A Psalm of David.
1The (A)heavens are telling of the glory of God;
And their (B)expanse is declaring the work of His hands.
2Day to (C)day pours forth speech,
And (D)night to night reveals knowledge.
3There is no speech, nor are there words;
Their voice is not heard.
4Their [a](E)line has gone out through all the earth,
And their utterances to the end of the world
In them He has (F)placed a tent for the sun,
5Which is as a bridegroom coming out of his chamber;
It rejoices as a strong man to run his course.
6Its (G)rising is from one end of the heavens,
And its circuit to the other end of them;
And there is nothing hidden from its heat.
7(H)The law of the LORD is [b](I)perfect, (J)restoring the soul;
The testimony of the LORD is (K)sure, making (L)wise the simple.
8The precepts of the LORD are (M)right, (N)rejoicing the heart;
The commandment of the LORD is (O)pure, (P)enlightening the eyes.
9The fear of the LORD is clean, enduring forever;
The judgments of the LORD are (Q)true; they are (R)righteous altogether.
10They are more desirable than (S)gold, yes, than much fine gold;
(T)Sweeter also than honey and the drippings of the honeycomb.
11Moreover, by them (U)Your servant is warned;
In keeping them there is great (V)reward.
12Who can (W)discern his errors? (X)Acquit me of (Y)hidden faults.
13Also keep back Your servant (Z)from presumptuous sins;
Let them not (AA)rule over me;
Then I will be [c](AB)blameless,
And I shall be acquitted of (AC)great transgression.
14Let the words of my mouth and (AD)the meditation of my heart
Be acceptable in Your sight,
O LORD, (AE)my rock and my (AF)Redeemer.
(SOURCE:http://www.biblegateway.com/passage/?search=Psalm%2019;&version=49;)
What is the pattern you ask? Though both names are name references to God, Elohim is used when the general relationship between God and mankind is referred. Thus, Elohim is the source of life, creator of the world, the God of all. On the other hand, when the bible talks about personal, intimate, and trusting relationships, it refers to God as YHWH.Thus, God is YHWH to Abraham, Isaac, Jacob, and to the whole Israel but God is Elohim to the rest of the world. Though Elohim cares for all mankind, YHWH gives his own people with special treatment. You should have noticed that shift in Ps 19:7. You should have noticed as well how it means for God to be your YHWH and not just your Elohim. YHWH means LORDship. It is personal, it is intimate, it is a trusting relatioship. It is good that the enlish traslations help us remember that. YHWH = LORD, Elohim = God. Now the question is WHO is the God to you? Is he Elohim, or is he the YHWH?
REFERENCE(S):
Walter C. Kaiser Jr., Peter H. Davids, F. F. Bruce and
Manfred T. Brauch. (1996): Hard sayings of the bible.
InterVarsity Press:Downers Grove, Illinois