I have been reading Surah al-Kahf and I find myself quite confused about ayat 9-22. What is this story about youths in a cave? It is presented like it should be a story that I am already familiar with, but I am not. Especially in ayah 22 where it gets into a discussion about how many youths there were and whether or not the dog counted among their number. Could someone help lend some background and context to this?
All perfect praise be to Allah
(Question was answered previously in comments, i am writing this answer on request of a member.)
Before coming to the story of the cave, here is some background.
Actually as muslims we believe that torah anjeel zaboor and quran are all from Allah, there were also other books but those are not known today. Allah sent many messengers and many books.
All of those messengers and books are right. And we idealize them. And we believe those books were revealed for either a community only or some were for the whole world but for short time, not forever.
And We have revealed to you, [O Muhammad], the Book in truth, confirming that which preceded it of the Scripture and as a criterion over it. Quran 5/47
As last prophet, we follow Muhammad peace be upon him and last book quran, which we believe is the last book revealed by Allah and is continuity of previus scriptures, which is for whole humanity and is the last book to be followed til the end day, which is perfectly preserved. And all other books are not preserved and have been altered, so cannot be trusted, some books vanished completely.
Now coming to the main question, about the story of cave
You will occasionally find many stories of old people and other things common in books like bible torah and quran, but we go with preserved quran's version. And we suspect the versions of bible and torah might had been altered.
For details on these ayahs and the tafsir you can lookup any good tafseer, i will recommend tafsir ibn kaseer. Google yourself or Read here or here.
And as you have found the reason yourself why the number of people is discussed, it is true that it is for the people who ask useless questions. Like the people who were ordered to take meat of a cow and they kept questioning and questioning issa(Jesus) and it got harder and harder for them to get meat of that specific cow. you can read that story here.