That was, at least, the story I was told when I was growing up. There is more to it, of course. As the asshole says, "It's a little bit more complicated than that." (The tl;dr version of this post is at the bottom, after the dashes.)
It starts with "the adversary" (the first appearance in the Bible of the word "Satan") saying to God that Job is only pious because he is prosperous. If he were no longer prosperous, he would curse God to His face. So, Job goes from having thousands of livestock, hundreds of slaves, and ten prosperous children, to having nothing at all but his wife. Then he gets sores all over his body. (Maybe it's leprosy. I dunno. Back then, every skin disease was leprosy.)
Three of his friend show up, to try to comfort him. They do a terrible job of it. They provide a shining example of the worst way to comfort a friend who has just lost everything and now looks like something out of a zombie movie. The dialogue is kind of like this:
Job: "Fuck this shit. I wish I had never been born. I wish I were dead. Compared to this, being dead would be awesome."
Friends: "Well, God disciplines those who have done wrong. You probably did something wrong, and he's teaching you a lesson."
Job: "No, I didn't. Some friend you are."
Friends: "We mean it. Why would God be unjust? Your children probably did something that made them deserve to die. If you were totally blameless, this wouldn't happen to you."
Job: "I didn't do anything, though. Seriously. And how can you defend yourself before God? He's, you know... God."
Friends: "Yeah, he probably knows more than you do about what you've done wrong. God kills wicked people all the time. He wouldn't do this if you hadn't done something wrong."
Job: "Okay, you know what? You guys are full of shit. Bad people prosper all the time, and good people die too soon. Also, you are terrible at this. Worst. Comforters. Ever."
Job: "No. Look. I will name for you a dozen things I could have done wrong, and I swear that I did not do any of them. Now, I want to know why God did this to me."
So then God shows up, and he is sassy as all get-out. Nowhere in the Bible is he this sassy.
"Where were you when I laid the foundation of the earth? Tell me, if you have understanding. Who determined its measurements--surely you know! ... Where is the way to the dwelling of light, and where is the place of darkness, that you may take it to its territory and that you may discern the paths to its home? Surely you know, for you were born then, and the number of your days is great!"Oh, snap!
Job doesn't respond with much more than, "Okay, I'm just going to shut up now. I thought I knew what was up, but I don't."
God finishes by turning to Job's friends and saying, "And you guys! You're even more wrong than Job is! What the hell is wrong with you?" And then he gives to Job double what he had lost. And they all lived happily ever after.
The story that many people take away from this is that God will pay you back when he takes things away from you. In my opinion, though, these people are not paying a lot of attention to the rest of the story. What I take away from it is this: "Sometimes bad things happen to good people, and it's nobody's fault. If you're asking, 'What did I do to deserve this?' then you are asking the wrong question, because God does not work the way that you think he does."
Now, I hope you can see how this might be vaguely related to philosophy. Even if you don't, it is relevant to some of the things I will be writing about in the coming weeks.