In many Ancient Near Eastern cultures, there was a political concept we call 'agency'. In this, the delegate or ambassador of a god simply spoke in the first person on that god's behalf. The use of agency is only touched on rarely in the broader historical narrative of Genesis–2 Kings, where we sometimes find the Messenger of YHWH speaking about YHWH in the first person.1 Two occasions where this agency concept are found most explicitly are:
"Behold, I send an angel before you to guard you on the way and to bring you to the place that I have prepared. Pay careful attention to him and obey his voice; do not rebel against him, for he will not pardon your transgression, for my name is in him. But if you carefully obey his voice and do all that I say, then I will be an enemy to your enemies and an adversary to your adversaries." (Exodus 23.20-22, ESV translation)
God's name (authority) is in the angel, and when the angel speaks, it is God's words.
Now the angel of the LORD went up from Gilgal to Bochim. And he said, "I brought you up from Egypt and brought you into the land that I swore to give to your fathers. I said, 'I will never break my covenant with you...'" (Judges 2.1, ESV translation)
The angel speaks, but his words are God's words.
Growing interest in angels
Today's critical scholarship generally agrees that the Genesis–2 Kings narrative was compiled and finalized sometime during or shortly after the Babylonian exile. (Second Kings concludes circa 560 BC.) After the exilic period, during the Second Temple era, we find Jewish literature become increasingly interested in heavenly politics and the role of angels.
This is especially the case in the apocalyptic genre. Whereas the earlier prophets claimed to receive their revelations directly from God ('the word of YHWH came to me', 'thus says YHWH', etc.), the Second Temple literature sees a drastic increase in angelic mediators of these revelations (Zechariah, 1 Enoch, Daniel, to name a few).
It's possible that sometime during this Second Temple period, the growing view that God delegated everything through his angels was read backward into those 'agency' seeds of thought found in the biblical narrative. In this way, readers inferred that God must have revealed the Law through an angelic mediator.
The Book of Jubilees
One such Second Temple text was the Book of Jubilees, a retelling of the Genesis-Exodus narrative written sometime in the second century BC.
It is in this book, perhaps, that we find the earliest references to the idea that God gave the Law to Moses through an angelic mediator:2
And [God] said to the angel of the presence, "Write for Moses . . ." (Jubilees 1.27)
And the angel of the presence spoke to Moses according to the word of the Lord, saying, "Write the complete history of the creation, how in six days the Lord God finished all his works and all that he created, and kept Sabbath on the seventh day and hallowed it for all ages . . ." (2.1)
Several more times throughout the book, this angel speaks in the first person:
"I have written in the book of the first law, in that which I have written for you . . ." (6.22)
"For this reason I have written for you in the words of the Law . . ." (30.12)
"All this account I have written for you . . ." (30.21)
"And behold the commandment regarding the Sabbaths — I have written them down for you . . ." (50.6)
". . . as it is written in the tablets, which [God] gave into my hands that I should write out for you the laws of the seasons . . ." (50.13)
Evidently, by the middle of the first century AD, this concept had become commonplace, at least among the Christian sect.
1 For a substantial treatment of this concept as it relates to the Messenger of YHWH, see: René A. López, Identifying the "Angel of the Lord" in the Book of Judges: A Model for Reconsidering the Referent in Other Old Testament Loci.
2 The following quotations from Jubilees have been adapted from the R.H. Charles translation.