The Church encourages us to pray for the dead since they may be in Purgatory needing our prayers. Praying for the dead is quite biblical. In the Book of Maccabees found in the Catholic and Orthodox Old Testament, Judas Maccabees took a collection for a sin offering for his men who died in battle:
For if he were not expecting that those who had fallen would rise again, it would have been superfluous and foolish to pray for the dead... Therefore he made atonement for the dead, that they might be delivered from their sin. [2 Macc 12:44-45]
St. Paul offers a short prayer for Onesiphorus and his family:
May the Lord grant mercy to the household of Onesiphorus... may the Lord grant him to find mercy from the Lord on that Day... [2 Tim 1:16 & 18]
Onesiphorus had died!
Whether dead or live, St. Paul intercedes (mediates) for him to God
(1 Tim 2:1-5).
In the Bible St. Paul writes about a purging fire that will purify our works "for the Day." St. Peter reminds us that our faith will be refined and tested by fire. Elsewhere in the Bible, the action of the Holy Spirit is described as fire. "He will baptize you with the Holy Spirit and with fire." [Luke 3:16] According to the Spanish mystic, St. John of the Cross, the fire of Purgatory is God's Love purifying our soul in preparation for the final beatific vision - the heavenly union with God. (Rev 22:3-5) "For indeed our God is a consuming fire." [Heb 12:29]
Peace