Allah T'ala says in the Holy Quran:
وَإِذْ أَخَذَ رَبُّكَ مِن بَنِي آدَمَ مِن ظُهُورِهِمْ ذُرِّيَّتَهُمْ وَأَشْهَدَهُمْ عَلَى أَنفُسِهِمْ أَلَسْتَ بِرَبِّكُمْ قَالُواْ بَلَى شَهِدْنَا أَن تَقُولُواْ يَوْمَ الْقِيَامَةِ إِنَّا كُنَّا عَنْ هَذَا غَافِلِينَ
(7:172) When thy Lord drew forth from the Children of Adam - from their loins - their descendants, and made them testify concerning themselves, (saying): "Am I not your Lord (who cherishes and sustains you)?"- They said: "Yes! We do testify!" (This), lest ye should say on the Day of Judgment: "Of this we were never mindful":
All human beings are bound in a covenant with God and a Day will come when they will be made to answer how well they were able to observe that covenant.
This event, according to several traditions, took place at the time of the creation of Adam. Apart from the prostration of the angels before Adam and the proclamation that man would be God's vicegerent on earth, all the future progeny of Adam were gathered, and were endowed with both existence and consciousness in order to bear witness to God's lordship. The best interpretation of this event is found in a statement by, 'Ubayy b. Ka'b, who has probably given the substance of what he had heard from the Prophet (peace be on him):
God gathered all human beings, divided them into different groups, granted them human form and the faculty of speech, made them enter into a covenant, and then making them witnesses against themselves He asked them: 'Am I not your Lord?' They replied: 'Assuredly you are Our Lord.' Then God told them: 'I call upon the sky and the earth and your own progenitor, Adam, to be witness against you lest you should say on the Day of Judgement that you were ignorant of this. Know well that no one other than Me deserves to be worshipped and no one other than Me is your Lord. So do not ascribe any partner to Me. I shall send to you My Messengers who will remind you of this covenant which you made with Me. I shall send down to you My Books.' In reply all said: 'We witness that You are Our Lord and our Deity. We have no lord or deity other than You.' (Ahmad b. Hanbal, Musnad, vol. 5, p. 135 )
This event has been interpreted by some commentators in a purely allegorical sense. They are of the opinion that the purpose of the Qur'an is merely to emphasize that the acceptance of God's lordship is innate in human nature. However, this was narrated in such a way as to suggest that the event did actually take place. We do not subscribe to this allegorical interpretation of the primordial covenant of man with God. For both the Qur'an and Hadith recount it not only as an actual happening, but also affirm that the covenant would be adduced as an argument against man on the Day of Judgement. There remains, therefore, no ground whatsoever to interpret the event in terms of mere allegory.
In our own view the event did take place. God caused all human beings whom He intended to create until the Last Day to come into existence. He endowed upon them life, consciousness and the faculty of speech, and brought home to them that there is no god or lord besides Him, and that Islam alone is the right way to serve Him.
If someone considers calling all human beings together in one assembly impossible, that shows, more than anything else the woeful paucity of his imagination. For if someone accepts that God has the power to create countless human beings in succession, there is no reason to suppose that He did not have the power to create them all at some given moment prior to the creation of the universe, or that He will be unable to resurrect them all at some given moment in the future. Again, it stands to reason that at a time when God wanted to designate man as His vicegerent on earth after endowing him with reason and understanding, He took from him an oath of allegiance. All this is so reasonable that the actual occurrence of the covenant should not cause any wonder. On the contrary, one should wonder if the event did not take place. (Commentary is taken from the Tafseer of Syed Abul 'Ala Maududi)