To expand on what COLOS said, justice is rendering to both God and one’s neighbor what is due to them.
Therefore, it would be unjust of us to suppose that God is not all Merciful - because we would not be giving Him his due. Another thing that comes to mind when I read the title of the thread
Is God fair with Hell or Heaven, is that if we don’t think He is fair, it means we think we have a better idea than Him …

… I seem to remember someone(s) in the Garden of Eden having a similar idea … funny how some things don’t ever really seem to change much.
The proper order or perspective according to St. Thomas Aquinas is that Mercy does not deny Justice - Mercy presupposes Justice ; in simpler terms , before knowing we’re going to be spared, we have to know what we deserved (what we’re being spared from).
The person in your first example could have just as easily gotten into Heaven if he had contrition in his heart as he was dying or, if as he experienced the
particular judgement were to ask for God’s Mercy.
Simillarly, if by the “last rites” you mean the sacrament of the Anointing of the Sick, the second guy could have still messed it up afterwards, or perhaps he wasn’t totally open to the sacrament when he received it - we don’t know; or as the Reginator says, “God only knows.”
Where so many of us seem to trip up is by reducing God who “the Heavens cannot contain” to a being that only our feeble limited minds can contain. The story of
St. Augustine and the little child by the seashore provides us with an adjustment.
If we’re interested in a personal view of How our Blessed Lord describes his Mercy and Justice to us in terms we might be able to grasp, St, Faustina Kowalska’s
diary is a good read. (Here’s her
Diary in a different layout which might be easier to read).
Several excerpts :
- On one of her visits to Pugatory
Diary No. 20 (Vision of Purgatory)
"One day I asked the Lord, ‘Lord, who else should I pray for?’ Jesus said that on the following night He would let me know for whom I should always pray for.
The following night, I saw my Guardian Angel who asked me to follow him. In a moment I was in a misty place full of fire in which there was a great crowd of suffering souls. They were praying fervently, but to no avail, for themselves; only we can come to their aid. The flames which were burning them did not touch me at all. My Guardian Angel did not leave me for an instant. I asked these souls what their greatest suffering was. They answered me in one voice that their greatest torment was longing for God. I saw Our Lady visiting the souls in Purgatory. The souls call her ‘The Star of the Sea.’ She brings them refreshment. I wanted to talk with them some more, but my Guardian Angel beckoned me to leave. We went out of the prison of suffering. * which said,
My mercy does not want this, but justice demands it. Since that time, I am in closer communion with the suffering souls."
- Our Blessed Lord describing his Mercy to St. Faustina:
“
My mercy is so great that no mind, be it of man or of angel, will be able to fathom it throughout all eternity.”
(so you don’t have to dig for this second one, it can be read at the top of
this page.
In real life, God will always offer His Mercy to the sinner - even at the very last possible moment. The key, is that we must accept.
How could we ever answer whether God is just, or fair , or not, with one or another when his Mercy is so great we can’t even conceive it ? Well, if His Mercy, as He says, surpasses even our own best estimation or concept of mercy in such immeasurable superabundance to a point we can’t even imagine, then, we with our flawed minds must certainly say He is fair … much fairer than any human could ever even imagine being.
To say or imply anything less, is to risk not giving God his due, or, as I heard a priest say in one sermon: :We humans, who are created in God’s image, seem to have this tendency to recreate God in our own image."

*