This questioning takes place on the Day of Judgement. This is a question of acknowledgment and a solid argument against human beings, as well as a declaration by the Messengers that they really did delivered the Message of their Lord (swt) onto the people they were sent to. This is why the Prophet (saws) asked on the day of the farewell pilgrimage:
“You will be asked about me, so what will you say?” To which they replied: ‘We testify that you have conveyed and fulfilled the message and given counsel.’ Then he raised his forefinger towards the sky, and pointing it at the people, he said: ‘O Allah, bear witness; O Allah, bear witness”, repeating it three times.”[1]
This question will be posted on people in the Hereafter, and the Messengers will be asked whether they have delivered the Message to their nations. It is a logical necessity for human beings when they come to this life to know who their creator is, who created the heavens and the earth. Allah (swt) has indeed put in our natural disposition an inclination towards believing. Just as the Prophet (saws) said:
“No child is born but upon Fitra“[2]
This is why we find in documentations and history books that all nations across the ages without an exception have a religion; either worshipping idols, fire, or people. Each age in time has a religion and this can only mean one thing, that humans are instinctively inclined towards being religious and towards believing in a higher super power. There are those who believed and followed the Prophets (PBUT), but also those who have deviated from the calling of the Prophets and instead they worshiped idols and similar things.
[1] Sahih Muslim, the Book of Pilgrimage, Hadith No. 1218.
[2] Sahih Al-Bukhari, the Book of Funerals, Hadith No. 1292.