Praise be to Allah.
Muslim (2767) narrated that Abu Moosa said: The Messenger of Allah (blessings and peace of Allah be upon him) said: “When the Day of Resurrection comes, Allah will give every Muslim a Jew or a Christian, and He will say: This is your ransom from the Fire.”
Muslim also narrated (2767) from Abu Burdah that he told ‘Umar ibn ‘Abd al-‘Azeez, from his father, that the Prophet (blessings and peace of Allah be upon him) said: “No Muslim man dies but Allah causes a Jew or a Christian to enter the Fire in his stead.” ‘Umar ibn ‘Abd al-‘Azeez asked him to swear by Allah, besides Whom there is no other god, three times that his father narrated that to him from the Prophet (blessings and peace of Allah be upon him), and he swore to him.
Ibn Maajah (4341) narrated that Abu Hurayrah said: The Messenger of Allah (blessings and peace of Allah be upon him) said: “There is no one among you who does not have two abodes: an abode in Paradise and an abode in Hell. If he dies and enters Hell, the people of Paradise inherit his abode. This is what Allaah says: ‘These are indeed the inheritors’ [al-Mu’minoon 23:10].
Classed as saheeh by al-Albaani in Saheeh Ibn Maajah.
An-Nawawi (may Allah have mercy on him) said:
“Ransom” means salvation and sacrifice. What this hadeeth means is that which is mentioned in the hadeeth of Abu Hurayrah: everyone has an abode in Paradise and an abode in Hell. If the believer enters Paradise, the disbeliever in Hell will take his place, because he deserves that due to his disbelief. What is meant by the words “your ransom from the Fire” is that you were exposed to the risk of entering the Fire, and this is your ransom, because Allah, may He be exalted, decreed a number for it to fill it. Because the disbelievers will enter it because of their disbelief and sin, they will become like ransoms for the Muslims.
End quote from Sharh Muslim by an-Nawawi (17/85)
Al-Qaadi ‘Iyaad (may Allah have mercy on him) said:
Because every accountable person has a place in Paradise and a place in Hell, whoever believes truly, his place in Hell will be replaced with a place in Paradise, but for the one who does not believe it will be the opposite, and it will be as if the disbelievers took the places of the believers in Hell. Moreover, because Allah has sworn to fill Hell, it will be filled with the disbelievers so as to save the believers from the Fire. So in that regard they are like a ransom for the believers. Perhaps the reason why the Jews and Christians are singled out for mention is because they are well known for their opposition to the Muslims and for being their opposites with regard to believing in the Messenger, which dictates that they should be saved.
End quote from Mirqaat al-Mafaateeh (8/3525).
To sum up all of that:
On the Day of Resurrection there will be a Jew or a Christian for every Muslim, who will be his ransom from the Fire. That does not contradict the fact that some Muslims sinners will enter the Fire for their sins, so that Allah may purify them thereof, because they will enter it, then they will be brought out of it by Allah’s mercy, then they will enter Paradise, where they will inherit what would have been the disbelievers’ places in it, because Allah has forbidden it to the disbelievers.
The words of the Prophet (blessings and peace of Allah be upon him), “Allah (st) will give every Muslim a Jew or a Christian, and He will say: This is your ransom from the Fire.” Indicate that this bounty will include all the Muslims, with no exceptions, because ransom is salvation, as mentioned above, and salvation will be for every Muslim. That is not contradicted by the fact that he may enter the Fire, because his entering it will be for the purpose of purification.
Ibn al-Qayyim (may Allah have mercy on him) said:
No evil doer or anyone who has a trace of evildoing will enter Paradise. Whoever is purified in this world and meets Allah pure and free of any impurities, will enter it with out ma’ooq. Whoever is not purified in this world, if his impurity is inherent, as in the case of the disbeliever, he will not enter paradise under any circumstances, but if his impurity is acquired because of sin and is transient, he will enter Paradise after having been purified in the Fire from that impurity, then he will be brought out of the Fire.
Endquote from Ighaathat al-Lahfaan (1/56)
Hence the Prophet (blessings and peace of Allah be upon him) said: “Whoever sats Laa ilaaha ill-Allah, it will benefit him someday in his life, no matter what befalls him before that.”
Narrated by at-Tabaraani in al-Mu ‘jam al-Awsat (6396); classed as saheeh by al-Albaani in Saheeh at-Targheeb (1525)
And Allah knows best.