As the title says, what are they doing until get attacked by Shere Khan? In the middle of the night in a cave. I haven't read the book or watch the 1967 movie.
Since the cave is not in the book, my guess is it was used by the movie writers as a more dramatic way to get Mowgli to the wolves, and show the danger of Shere khan. My thought from the movie was they were meant to have been traveling from one village to another, and made their campsite in the cave for the night. That is just a guess, but I think it stands up knowing that it was created for the movie.
From the book:
‘My quarry. A man’s cub went this way,’ said Shere Khan. ‘Its parents have run off. Give it to me.’
Shere Khan had jumped at a woodcutter’s campfire, as Father Wolf had said, and was furious from the pain of his burned feet.
In the book Mowgli's parents were woodcutters, and they did not get killed by Shere Khan. Mowgli ran off in the confusion, and when he ran into the wolves cave he was bold, and so the wolves took him in and defended him.
Later on he does meet his mother from what I remember, but I can't recall anything about his father, so the writers probably felt safe in killing him off with the cave scene.
Although Sleeping in a cave until daylight isn't usually a good idea because most of the caves are inhabited by wild animals (carnivores which prefer to hunt alone).
Weather might have forced them to move inside the cave , Shere Khan attacked them for intruding his territory.
Or there is also a possibility that Shere Khan was attracted towards them by noticing something shiny (Fire) which led to the attack.