It is generally thought that the Jews were at first polytheistic, worshipping a large pantheon of Canaanite gods, with YHVH as the chief god. The general theory about how the Jews turned to monotheism involves the development of monolatrism - the recognition of the existence of other gods but the worship of only one - during the reforms of King Josiah in the 7th century BCE, which evolved into monotheism during the Babylonian Exile in the 6th century BCE.
However, the papyri found in the Jewish Temple at Elephantine in Egypt, dated from the 5th century BCE, describe the worship of not only YHVH, but also other deities. One easy explanation could be that the Jewish community at Elephantine predates King Josiah and the Exile and is thus a relic of First Temple Judaism, yet that community was as I understand it a border garrison established by the Persians, and thus must have been established after the Exile.
How to resolve that contradiction? Is it possible that monotheism was not established yet in the Persian period, or did multiple Judaic religions, polytheistic and monotheistic, coexist at the time?
The most parsimonious answer is that the fortuitous "discovery" by Josiah of the Torah during temple renovations is a literary fiction just like Moses' writing of the Torah and Ezra's introduction of the lost Torah after the exile. All attempt to provide a pedigree for the Torah and explain why it was not previously known to the Israelites. Furthermore, current sentiment by scholars seems to be that the archaeological evidence also does not support the Josianic reforms.
I recently posted a comment on this topic at /r/academicbiblical, which I'll repeat below with relevant citations.
Finnish scholar Juha Pakkala, in a paper "Why the Cult Reforms In Judah Probably Did Not Happen", argues on the basis of the Elephantine evidence and the complicated redactional history of the Josiah passages in Kings, among other things, that the narrative is not reliable.
Russell Gmirkin has some interesting observations on the problem of trying to use stories like Josiah's supposed reform in order to date the Pentateuchal sources in a recent paper:
De Wette believed that the date of Deuteronomy was fixed by the biblical account of the purported discovery of an ancient scroll of the law in the temple in 621 BCE during the reign of Josiah, which prompted righteous Josiah to institute a series of Deuteronomistic cult reforms. A second chronological linchpin was the return of Ezra the priest from Babylon in ca. 458 BCE, which Wellhausen proposed as the historical background for the introduction of P. (p. 8)
The supposed chronological clues provided of the Josiah reforms and the return of Ezra the priest rested on an uncritical acceptance of these two biblical episodes, as well as an imaginative historical reinterpretation of these self-same episodes: priests in the time of Josiah did not discover an ancient scroll of the law dating from Mosaic times (2 Kings 22.3-10), but created a Deuteronomistic literary forgery; and Ezra did not return from Babylonia with the ancient books of Moses (as implied by Neh. 8.1-8), but introduced a new set of priestly legal revisions added onto the inherited Pentateuchal text. Historical critical dating of D and P thus required both the acceptance of 2 Kgs 22 and Neh. 8 as substantially accurate historical narrative while simultaneously subverting their historical content in order to read them as foundation stories for the D and P sources. (pp. 9-10)
It is doubtful that a single normative Judaism existed at any point in time as proposed in the Documentary Hypothesis. Archaeology has not corroborated the reforms under Hezekiah and Josiah described in Kings. See Lisbeth S. Fried, “The High Places (Bāmôt) and the Reforms of Hezekiah and Josiah: An Archaeological Investigation,” JAOS 122 (2002): 437-65; cf. Gmirkin, Berossus and Genesis, 27-28, and the literature cited there. Iron II inscriptions and the Elephantine Papyri document Jewish polytheism down to the Persian period (Gard Granerød, Dimensions of Yahwism in the Persian Period: Studies in the Religion and Society of the Judaean Community at Elephantine [BZAW 488. Berlin: Walter de Gruyter, 2016]). (p. 34, n. 74)
Source: "Can the Documentary Hypothesis be Rehabilitated?", JHC 15/2 (Fall 2020)
Abstract from the paper by Lisbeth Fried cited above:
This paper investigates the historicity of Hezekiah and Josiah's reforms of the bāmôt. A description of a bāmāh is derived from the biblical text. Structures matching the description are then sought in Iron Age II cities of Judah and Samaria. Cult sites matching the description are found, but these sites were not destroyed as a result of the edicts of these reforming kings. Rather, they were destroyed during the onslaughts of Pharaoh Sheshonq I and of the Assyrian kings Tiglath-pileser III, Shamaneser V, and Sennacherib. The historicity of the reforms is not supported by archaeological data. The paper concludes with a brief discussion of the principle of continuity of sacred space, the Sitz im Leben of Deuteronomy 12, and the date of the Deuteronomist.
To put Gmirkin's argument another way, scholars who support the traditional Josanic reform are trying to have their cake and eat it too. On the one hand, they're saying that the narrative of Samuel-Kings — which is manifestly ahistorical in other places, incidentally — is true in this instance, and the Torah (or at least, Deuteronomy in some form) was first introduced by king Josiah, paving the way for monotheism. On the other hand, they're also saying that the narrative is deliberately deceptive, and that Josiah's priests didn't "find" the Torah but actually wrote it themselves and then pretended to find it. Since this position requires the story to be deliberately misleading in the first place, there's no good reason to trust any of it without corroborating evidence.
In a wider sense, this kind of circularity has always been a problem in biblical studies. Scholars would invent a historical context on the basis of a biblical passage for which there was no strong archaeological or historical evidence. Then they would show how well the biblical story fit into that context, as if that were evidence for the story being true. Increasingly, scholars are going back to the drawing board and asking, "what does the history of Palestine look like if we interpret the biblical text through the lens of archaeology instead of vice versa?"
So I have a follow-up question that's a lot more basic. I had kind of a vague understanding that Judaism had evolved out of a polytheistic belief, but I had no idea that there were still major elements of polytheism well into the final millennium BCE. Are there any good sources that can give a much more general overview of early Judaism and how it became monotheistic?