Why did this group of people decide to worship a s single god while most of their neighbours were polytheists? What was the origin and purpose of Torah with all of its complex rules?
These questions are very heavily loaded with their own history of religious and political interest, so the answers are generally very controversial.
Karen Armstrong argues that "Monotheism out of nowhere" isn't correct because Judaism itself developed gradually from polytheism to a cult of a specific god that claimed supremacy and only later became monotheistic. The documentary hypothesis seems to support that.
purpose of Torah with all of its complex rules
That's even more complicated due to the multiple authorship. Israel Finkelstein and Neil A. Silberman (The Bible Unearthed: Archaeology's New Vision of Ancient Israel and the Origin of Its Sacred Texts, especially part 3) point out that it had a large role as unifying national epos. Parts of the torah like 2. Kings 22 definitely speak for that.
You may wish to ask the question in /r/AcademicBiblical as well.
Somebody is going to have to explain "monotheism". From a pagan point of view: angels, devils, demons, spirits, gods, what's the difference?