One very close possibility or an example of prayers for the dead happened at David’s time. In 2 Samuel 21, a three-year famine was inflicted at Israel and by the Lord’s message the reason for it is Saul’s actions to the Gibeonites, whom he sought to exterminate. They had still nurtured grudges to the fallen King.
The Gibeonites demanded seven men from Saul’s kinsmen to be killed to pay as retribution. David spared the son of Jonathan by an oath they mutually made when Jonathan was still alive.
That time the bones of Saul and Jonathan were displaced. David took them and buried them together with Saul’s father Kish’s bones and the bones of the seven men who were killed by the Gibeonites. At that time prayers rose and God restored the Land (cf. 2 Samuel 21:1-14)
I think David did pray on the behalf of the dead here for he knew by the counsel of the Lord that the famine was caused by Saul’s ruthless acts. And of course, it is reasonable for him to pray for we know that David treasure Jonathan dearly (that made him decide to spare Jonathan’s son). No good friend can withhold wishing the good for his own friend who had been good to him, too, so he must have prayed for Jonathan also, especially in the truth that Jonathan was ever associated with his ruthless father. Notice here that it is on the burying of the dead in the proper place of burial (that is, with Saul’s father Kish) that the curse in Israel was lifted up. I think it is reasonable enough to say that David did pray to God on behalf of the dead,** for if God wills the affairs of the long dead to linger on, like the sins of Saul to the Gibeonites, then our actions must be very meritorious if we correct it for the sake of the dead.** And doing or praying for them is one action. Thus our Deuterocanonical Sirach says that:
“A gift hath grace in the sight of all the living, and restrain not grace from the dead.”
In this tradition the importance of proper burial and burial rites strengthened among the Jews. I think why the Jews are terrified by unburial is that they’re afraid that their past actions will linger on and no one will pray on behalf of them.