“A reasonable way out of this predicament is to contextualize these passages and one way to do that is to take 2:213 as indicative of the essential relatedness of human beings before God. This approach draws from verse 172 of Sura 7 ( al-A’raf ) in which God calls forth all the descendents of Adam — all of humanity — and asks them who is their Lord, and they all affirm the lordship of God. The notion of a single community of mankind in 2:213 can be taken to point to this transhistorical covenant between God and all of mankind as descendants of Adam. The unfolding of history then tests humanity on their allegiance to the lordship of God and its implications, and prophets are sent to remind people of their duties and warn them of the consequences of their violations. Now verse 5:48 is explained as addressing not the transhistorical singular community of the descendants of Adam, but the historical communities formed by the allegiances of the humanity to the various prophets that God has sent. The verse is beautifully tolerant of the plurality of the faithful communities and demands that the prophet Muhammad preserve this plurality. The inhabitants of these communities are not heretics, for not being nominal Muslims, but, in fact, they carry out the will of God and spread virtue.”
Reference:
https://jsr.shanti.virginia.edu/back-issues/vol-6-no-1-may-2006-scripture-and-democracy/islam-liberalism-and-democracy/
Please also see Footnote to 2:213 in Muhammad Asad’s commentary to Quran, which corroborates the above view:
“What is alluded to in this verse is no more than the relative homogeneity of instinctive perceptions and inclinations characteristic of man’s primitive mentality and the primitive social order in which he lived in those early days. Since that homogeneity was based on a lack of intellectual and emotional differentiation rather than on a conscious agreement among the members of human society, it was bound to disintegrate in the measure of man’s subsequent development. As his thought-life became more and more complex, his emotional capacity and his individual needs, too, became more differentiated, conflicts of views and interests came to the fore, and mankind ceased to be “one single community” as regards their outlook on life and their moral valuations: and it was at this stage that divine guidance became necessary.”