There is 0 conclusive contemporaneous historical evidence that King David actually existed.
The Torah itself... was likely written and compiled during roughly 500 BC to 300 BC. David is traditionally supposed to have existed in approximately 1100 BC to 1000 BC. The oldest supposed reference to David is from 925 BC, and this interpretation of a highly damaged relief is contested, theres again 0 contemporaneous evidence, and just a scant bit of contentious/dubiously providenced evidence later than that.
https://en.wikipedia.org/wiki/David#Historicity
https://en.wikipedia.org/wiki/Davidic_line#Historicity
Given that much of the Torah more or less seems to be a fantastical rewriting of the history of the people exiled from Judea/Canaan/Israel, largely put together when/after they were allowed to return to their homeland by Cyrus, after Persia conquered the Neo Babylonians, so that they could strengthen their group identity with a collective mythic origin...
In all likelihood, if David was real, he would have been more like a chieftain of basically a large village, who was then tall-taled into a much exaggerated ruler of a much exaggerated 'Kingdom', in furtherance of creating that collective unifying myth.
Hopefully I do not need to tell you Moses and Joshua are entirely mythical figures, the Exodus did not actually happen, nor did the Israelite conquest of Canaan.
The reason why God is a jealous God and you shall have no other representations of any other Gods and he smites all other Gods and such is because Yahweh more or less is El + Ba'al, renamed, and amalgamated with the attributes and titles and escapades of other Canaanite deities. The Yahwist cult was an offshoot of the general Canaanite religion, that started roughly somewhere bewteen the 13th and 9th centuries BC, that decided their amalgamation God was superior to the original pantheon.
https://en.wikipedia.org/wiki/Yahwism
The tale of the conquest of Canaan by Joshua is basically a dramatized allegory of the Yahwists gaining traction and popularity in Judah/Israel.
After that group returned from Babylon to their original homeland, influenced by the two-god paradigm of Zoroastrianism... their original homeland was at that time populated by people whom some of which were Yahwists, but many of whom more or less still held to the polytheist version of Canaanite religion.