I've always wondered why, if God is all-knowing, did he agree to spare the people of Sodom and Gomorrah if ten righteous people can be found within it. He knows full well that ten people won't be found, so what is the point? Is it just a test? Is he having a laugh at Lot/Abraham's expense?
You are talking about the god of Abraham. Sodom and Gomorrah, in the Bible, have their own gods. Gods fought each other just like their cities did. The Semitic pantheon was similar to the Indo-European pantheons that way.
The story of Sodom and Gamorrah is very old, much older than most of the rest of the Bible. It tells the story of two truly ancient cities that existed before Exodus, before the nation of Israel was even founded.
In the story, Abraham's god reveals himself to be the one true and only god, the entity we now spell with an upper-case "G" because in that sense the word is a name. (In fact, "the name", in Hebrew "hashem", is the term Jews usually use to refer to the entity.)
So why did G-d agree to spare the cities if ten righteous people can be found? That's an ancient question, one of the mysteries of Hebrew legend. It's not something that just missing and that was only now noticed (by you first, perhaps). It has been argued over for (literally and in every sense of the word) millenia.
The rabbis (in this context the term means "the sages that wrote the Talmud") stated that next to the written Torah (books of Moses), an oral Torah existed, containing details never written down until Talmudic times. Among that oral legend you can find the millenia-old discussion about this subject and Talmudic texts also discuss the matter. It is far from easily solved.
My own stance is that perhaps, while G-d can kill whomever He wants in the world He created, G-d wanted to do Abraham a favour to show Abraham that He is indeed capable of not only creating and destroying but also of mercy. Creation, destruction and mercy are three key components that need to be taught to the founder of a nation. (In fact Abraham founded several nations, but that is besides the point.)
The part I don't understand is why people thousands of miles from Israel who are not of the people of Israel show such great interest in our legends. Do I discuss native American Indian stories all day long trying to find something I could consider an inconsistency? I don't. Their legends serve them well, and ours do serve us well. I think all people on the planet have ancient stories about gods that behaved funny.
Think of the Greek legends. Heracles was driven mad by Hera, wife (and sister!) of the god Zeus. Heracles then proceeded to kill his own six children. (Abraham nearly killed one of his, but G-d told him that it was only a test and that children must never be sacrificed.)
The god of Abraham also originally had a wife. Her name was Asherath and she was still being worshipped in Israel 2200 years ago, archaeology shows. As far as I know she is at least not also his sister.
Either way, the story of Sodom and Gamorrah was one of several stories explaining the new concept of having only one god who can do everything rather than several gods that fight each other. That's the purpose the story serves and that's why it was written down and kept intact over the millenia. What actually happened (I assume the cities really did exist and where destroyed by a natural disaster) isn't the point any more. But the missing information is either part of the oral legends or lost or never existed. But the fact that the information is missing doesn't mean that there is anything wrong with the story.