I don't find the answers in the book of Job very satisfactory. It seems to me that they likely borrowed that story from the Babylonians.
There are many Ancient Near Eastern texts referring to the suffering of the righteous (e.g. the Akkadian Ludlul bel nemeqi), but afaik nothing has been found yet from which the book of Job could be said to have been "borrowed". It is evidently an original Hebrew composition, built around the name of an old legendary character whose original story was perhaps completely different (cf. Ezekiel 14:14,20, where Job appears together with a Danel who is probably the hero of the Ugaritic Epic of Aqhat, which has almost no connection with the later Daniel character, and Noah who was probably not connected with the Flood either). Putting him in a non-Israelite setting is part of the literary fiction.
The book of Job is difficult to read because it has been poorly transmitted, and it is actually obscured by its clearest parts / additions (such as the prose Prologue / Epilogue, the discourse on Wisdom in chapter 28, Elihu's discourses or Yhwh's discourses -- at least the second one). Perhaps it was just too provocative to be transmitted without some misunderstandings. But it is nonetheless (or, all the more) fascinating...
Narkisssos, my old Interpreter's Bible mentions that the essential story may have been oral or written folk tale of Edomite origin. As you said, odd contradictions exist that suggest multiple authors. Job is apparently a nomadic sheep herder then he is a respected city dweller in the end of the book. He also says he lives in a house yet said later to live in a tent. The poem makes not even a single mention of the testing or to sacrifices yet these are central to the prologue. The characterization of Job in the poem is quite negative as compared to the flawless image in the pro and epilogues. The use of YHWH and El in the various parts also is noted. The overall styles are quite different between the poem and the material surrounding. A great many linguistic markers separate the sections. The book is a great work, that will be argued for many years to come.