Ek Gharhi Ke Simraney Paapi Tharey Anek
Raja Janak is considered to be a great king of ancient times who was a very Dharmi(righteous) king.
Bhai Gurdas Ji has written about King Janak in his Vaars:
bhagath vaddaa raajaa janak hai guramukh maayaa vich oudhaasee
King Janak was a great saint who amidst maya remained indifferent to it.
dhaev lok no(n) chaliaa gan ga(n)dhharab sabhaa sukhavaasee
Along with gans and gandharvs (calestial musicians) he went to the abode of the gods.
jamapur gaeiaa pukaar sun vilalaavan jee narak nivaasee
From there, he, hearing the cries of inhabitants of hell, went to them.
dhharamaraae no aakhioun sabhanaa dhee kar ba(n)dh khalaasee
He asked the god of death, Dharamrai, to relieve all their suffering.
karae baenathee dhharamaraae ho saevak t(h)aakur abinaasee
Hearing this, the god of death told him he was a mere servant of the eternal Lord (and without His orders he could not liberate them).
gehinae dhharian eik naaou(n) paapaa(n) naal karai nirajaasee
Janak offered a part of his devotion and remembrance of the name of the Lord.
paasa(n)g paap n pujanee guramukh naaou(n) athul n thulaasee
All the sins of hell were found not equal even to the counterweight of balance.
narakahu(n) shhuttae jeeaa ja(n)th kattee galahu silak jamafaasee
In fact no balance can weigh the fruits of recitation and remembrance of the Lords name by the gurmukh.
mukath jugath naavai(n) kee dhaasee a
All the creatures got liberated from hell and the noose of death was cut. Liberation and the technique of attaining it are the servants of the name of the Lord.
After a long life of mediation and naam abhiyaas(meditation), King Janak gave up his body. A divine chariot descended and King Janak's soul boarded it. On the way the chariot came near to the abode of Dharam Raj, the lord of death. There, sinners were suffering punishment in millions of hells. When the wind that had touched the soul of King Janak came to them they felt great joy and their misery disappeared. Then those persons, oppressed by sins, wanting to keep King Janak's association, began to lament. They spoke piteously to King Janaka, "O blessed one. Please do not leave. We who are greatly tormented are feeling happy due to contact with the breezes that have touched your body."
Hearing their words, the very righteous king became filled with pity and thought to himself, "If due to the touch of the breezes that have touched my body I am bringing some happiness to the residents here, then I will stay in this place. This is heaven for me."
Thinking like this, the king stayed there by the gateway to hell. After some time, Dharam Raj himself came to that gateway. There he saw King Janak, full of mercy and a doer of great meritorious deeds, standing by the doorway.
Dharam Raj smiled and said to King Janaka, "O king! You are sarva-dharma-siromani - the crest jewel of piety. Why have you come here? This is a place for wicked sinners who cause harm to others. Men like you who perform meritorious deeds do not come to this place."
Dharam Raj then said, "Those persons who do not remember the Lord with their mind, words, or deeds I throw them into hell and punish them. Those who have remembered the Lord leave the sufferings of hell and quickly go to Heaven.
"O very intelligent king, my servants, unable to even look at persons like you, bring those who are great sinners. Therefore you should leave this place and go to lords abode.
Hearing the words of Dharamraj, with great compassion King Janaka replied, "O Dharam Raj, out of pity on these beings I shall not go to Heaven. Although situated in this place, they are feeling some comfort due to the breezes blowing past my body. If you release all of these persons living in hell then I shall be happy and will proceed to Heaven."
Hearing the words of King Janaka, Dharam Raj pointed out to him each of those living in hell and said told the king why they were in hell and the punishment each one of them was going to receive.
After making all of these persons eat the fruit of their sins, I shall release them. O best among men who have accumulated vast amounts of religious merit, please leave this place.
Having pointed out the sinful persons, Dharam Raj became quiet. With his eyes full of tears, King Janaka, the great devotee of the Lord, said, "Tell me, how can these miserable beings quickly be set free from hell and attain happiness?"
Dharam Raj replied, "These persons have never worshiped the Lord. How then can they be free from hell? O great king, if you desire to release them, even though they are great sinners, then give them the following religious merit possessed by you: Once, upon getting up in the morning, you meditated with a pure heart upon the Lord— the remover of great sins. Give them the religious merit which you obtained that morning when with a pure heart you uttered, "Rama, Rama." Obtaining that merit, they will get freedom from hell."
Hearing these words of the intelligent Dharam Raj, the great king Janak gave those persons the religious merit obtained by him from his birth. King Janak said, "Let these persons be released from hell due to the religious merit earned by me from birth by the worship of God."
As soon as he said this, those persons dwelling in hell immediately were freed from their suffering condition and obtained divine bodies. They said to King Janak, "O king, by your favour, in one moment we have been freed from miserable hell and will now go to the highest position."
All the sins of hell were found not equal even to the counterweight of balance. In fact no balance can weigh the fruits of recitation and remembrance of the Lords name by the gurmukh. All the creatures got liberated from hell and the noose of death was cut. Liberation and the technique of attaining it are the servants of the name of the Lord.
Seeing those now-effulgent persons freed from hell, King Janak, who desired the welfare of all beings, was very pleased in his mind. All those persons praised the great King Janak, the very treasure house of compassion, and went to the spiritual world.