http://www.drbo.org/x/d?b=drb&bk=46&ch=12&l=46#x[46] It is therefore a holy and wholesome thought to pray for the dead, that they may be loosed from sins. [2 Machabees 12:46] [Latin]
[footnotes]
[46] It is therefore a holy and wholesome thought to pray for the dead: Here is an evident and undeniable proof of the practice of praying for the dead under the old law, which was then strictly observed by the Jews, and consequently could not be introduced at that time by Judas, their chief and high priest, if it had not been always their custom.

Why would we pray for them if they are in Hell? Those are forever lost.
Why if they are in Heaven? They have no need of prayers.
Logical.
God Bless!