It is well known that the Prophet, may Allah bless him and grant him peace, mentioned this to praise those people for their patience and steadfastness, and so that their example might be a source of strength for the believers of this community.
This is also indicated by what Allah related concerning the People of the Trench, when He said:
“Indeed, those who persecuted the believing men and believing women…”
Surah al-Burūj, 10.
Muslim narrated their story at length in his Sahīh, on the authority of Suhayb. It relates that the monk remained steadfast until he was killed, and that the boy gave instructions for his own killing, knowing that this would lead the people to believe when they witnessed that sign. Once the people believed, the disbelievers persecuted them to make them turn back from their religion, but they refused. Even when one woman wanted to turn back, Allah caused her infant to speak, saying, “Be steadfast, Mother, for you are following the truth.”