In surah Kahf, Allah specifically mentions that the people of the cave were in their youth. Allah does not normally mention these types of details this so it is something significant. Allah wants us to know that they were youth for a reason.
These were people who lived in a time where disbelief was prevalent and they were among the few believers. They were firm in their belief and did not give in to society pressure. Despite their lives being threatened they still held onto their faith. So Allah rewarded them for it. They were saved from the tyrannical ruler and when they returned home they found people who could openly practice their belief. Allah made them examples for us to follow by speaking about them in the Quran.
It is We who relate to you, [O Muhammad], their story in truth. Indeed,
they were youths who believed in their
Lord, and We increased them in guidance.
And We bound [i.e., made firm] their
hearts when they stood up and said,
“Our Lord is the Lord of the heavens
and the earth. Never will we invoke besides Him any deity. We would have
certainly spoken, then, an excessive
The youth today should take from this and realise that they should not be worried about conforming to society, rather if they stay firm on their deen then Allah will surely save them and reward them. Just like He did for the people of the cave.