Well I'm not a Bible literalist in the sense that everything in the Bible has to be taken so literal rather than the scriptures using stories and illustrations to portray deeper meanings or lessons. In fact, spiritual literature is very much like that in general not just the Bible....And I'm not just making excuses the Bible weaves in and out of literal and figurative throughout the whole book, in other words it doesn't have to be just one or the other it is both. It uses a lot of symbolic writing styles as well, metaphors, analogies and things alike. Anyone who doesn't know that just simply doesn't know the Bible. I've been reading it since I was a kid so I just happen to get its style.
I'm also not a model of fundamentalist religious systems either so I'm considered a heretic anyways lol. (Not that I particularly care).
Not that this has anything to do with what you asked really, other than I believe the focus of such accounts should be more on the principles involved rather than focused on the objects, people and settings. This is where people get tripped up, the meaning behind such accounts seems to simply evade them.
Anyways two things I wish to point out for you, keeping in mind we're just looking for what makes sense about the story. Number one, people seem to forget that the God of the Bible can be surprised, disappointed, have regrets and even change His mind. I only point this out because when God tests individuals...- although God may have an idea of what someone may choose - God can be joyed or displeased with an outcome. So it seems to me this idea that the God of the Bible knows everything is somewhat of a blurred concept. The Noah's Ark tale just as an example says that God regretted He made man and His heart was deeply troubled. If it was so that everything was known how could that be true? there are also examples of the Bible God changing His mind according to mans choices. So it seems to me God was more an Observer rather than a Puppet Master in relation to created beings.
Now this is going to sound contradictory to what I just wrote somewhat but let me say this, I do think God probably knew what Job would do because the challenge was set for Satan that Job would remain faithful to God. The challenge wasn't that God would see Jobs faithfulness but that Satan would observe it by testing Jobs resolve. So in this particular event God was definitely familiar with Jobs faith, otherwise the test would have been worthless.
Why did God do this? because supposedly Satan challenged God and mocked his servants faith in the midst of a counsel lol. Sounds like a silly reason but again, we are just focusing on principles here. And so it wasn't God that did cruel acts to Job it was Satan, God just observed it.
So getting to the moral of the story since that is what I believe the focus should be on. It's basically the same theme throughout the entire Bible really, which is to trust God and put God above all things no matter what goes on around us. Now in the end Job would also learn no matter what we could lose in this life God would always be there and God could always restore the worst case scenarios no matter the loss.
It is a change in perspective, to see how fleeting and temporary the possessions and material gains of this life can be and that any minute they could be lost. To me, it's an exaggerated example meant to make our personal trials look smaller, seeing that Job was able to not only maintain his loyalty to God but that he could also make it through something so terrible and gain back what he lost. Most of us will never have to face such a terrible story, at least not on the scale Job did. But, even if we did it gives us a sense of hope.
When I was young at the time, it helped me because I had a shaky childhood and a poor upbringing. My family was broken, they were all hurt people so I never really had a solid foundation so I learned pretty early I was not going to be able to rely much on any of it. At an early age I had already made up my mind I wasn't going to put any emphasis of hope or faith in people or material possessions. I was going to make God my rock and my fortress and maintain my faith and passion for the Creator no matter what I went through. And I did, I've had to build my own life out of nothing and I've kept my faith and unwavering passion for God all these years.
I know this may come across as funny, but I'm just giving you an idea what a story like this can inspire. There's a lot of strange tales in the Bible, but they have a powerful beating heart beneath them of spiritual principles and meaning which is why I tend not to focus too much on the surface of them. That came naturally to me as a kid anyways, which is why I'm always scratching my head when people debate these topics. It's like atheists have zero perception of what the underlying principles are.
But to answer your initial question, it wasn't about what God knew would happen, it wasn't a test for God but the other two parties involved. To me though, it's just a story about hope meant to inspire. Sorry about rambling, I was just showing you another way of looking at a story like this. It often comes up in question, why would God gamble with someone's life in that way, that it seems rather petty the way it started. I agree, that's why I tend to think it's probably more of a figurative tale than how God would deal with people. Either way, whether it be literal or figurative what I wrote about the underlying meaning maintains its conclusion.
What do you think, would you tend to think this is something that literally happened or rather writers using metaphorical styles to convey messages?