Much of this can be explained by the fitful development (over centuries if not millennia) of a belief in an afterlife at all–much of which development seems to come from considering the promises of God to Israel. Sometimes characters in the story get glimpses of the notion of a resurrection and restoration (of Israel at least) in the day of the YHWH to come. Other times, everyone goes to sheol, the end (though God continues on).
By the time of the Judaism represented in the NT, several hundred more years had passed, and many religious experts firmly believed in the resurrection to come (or possibly survival as bodiless spirits, although there’s more evidence of the former.) A major belief in survival and (even more importantly) restoration after death is clearly indicated both by Jesus (in Gospel report) and by the NT authors.
This brings up the problem of what happens to the wicked, of course–not least because (and the NT keeps this idea, sort of) the wicked and the righteous share principly the same fate: going down into the pit/sheol/hades. One of the really interesting things (and mainstream Judaism had its adherents of this belief as well) is that this parallel fate (not in the classical Greek sense of ‘fate’ of course, but the popular sense we’d speak of nowadays) continues at least through the resurrection: the good and evil are resurrected to judgment, with the good being resurrected to life eonian and the wicked being resurrected to eonian crisis (or brisk-cleaning or chastisement or alloy-testing or several other words of this effect. Of equal interest is that the terms themselves are not intrinsically hopeless.)
Anyway, it isn’t unusual that as the notion of life after death becomes more clear, the notion of what happens to the unrighteous after death becomes more important–and rather choppy. (The fate of the righteous was a big DUHHH!!! But the unrighteous obviously share the same fate in some key ways at least up to a point, so there isn’t some total ditch separating them. Even in the GosLuke parable featuring a big ditch in hades. )
There are however numerous bits of testimony in the OT to the effect that God intends to save and restore the pagan nations around Israel, too. But the main focus is on Israel. And not only on believing righteous Israel, but on the restoration of traitorous unrighteous Israel. So we find things like chp 31 of Jeremiah, where it is not only a righteous remnant who will be restored by God–although that too–but the children whom “Rachel” is weeping over “for they are not” (a euphamism for death, as the author of GosMatt also uses it). And not only the righteous dead shall be restored; but at least half (maybe more) of this particular prophecy is directed toward “Ephraim”, the rebellious son–also considered as a daughter in the poetic language of the prophecy, but the reference as a son is especially important because it points back to King David’s slain rebel son over whom he grieved when Absalom was slain in his rebellion in the forests of Ephraim. (The prophecy ends with a riddle: “How long will you go here and there, O faithless daughter?! For the Lord has created a new thing in the earth: a woman shall encompass a man.” In some way, a woman encompassing a man in a “new way” is to help Israel the faithless child, Ephraim slain by God, return to God.)
There are things of this sort all over the OT, once one knows what to look for. It isn’t spelled out in any systematic way, and it’s hard to derive a systematic theology from it, too. A reader of Jeremiah 31, for example, could very reasonably say that God (or the prophet) is only being poetic about the reference to Ephraim. Poetic implications, by their nature, can often have wide possible interpretations. (This is a main reason not to push the theological lessons of parables too far, too.)
In any case, NT authors (and Jesus) are quite clear (if not always clear in intention) about there being afterlife punishments of various sorts. OT authors sometimes see Israel being restored, every once in a while see her rebel sisters being restored, talk about the utter destruction of the wicked a lot (but include in this the people who are going to be restored by God someday, chiefly rebel Israel, whatever this ‘restoration’ is supposed to mean, but also ‘Sodom’ and ‘Leviathan’ for example, even the latter of whom is slated to be tamed by God and recovenanted, just like Israel!)–but rarely if ever talk about punishment after or concurrent with restoration. (Jer 32, btw, could be said to hint about this: after restoration, a person will no longer have to suffer punishment for unrighteous deeds done by ancestors or peers, but only the one who eats sour grapes will have his teeth set on edge.) This is why some commentators (both Jewish and Christian) claim there is no doctrine of ‘hell’ in the OT, in the sense of hopelessly ongoing conscious torment. Christian commentors (and some Jewish ones, especially from the days collected in the Talmud) may say that this revelation is hinted at here and there but is only fully given later. (In the NT for Christians; in rabbinic commentary for Jews.) Other Judeo/Christian commentors may conclude the OT teaches annihilation; and so therefore the NT must also (per these Christians.) Even if God resurrects the wicked first before annihilation.
(“I like to play with things a while!–before annihilation…” – Max Von Sydow as Ming the Merciless, finishing the voice-over prelude to the 1980s version of Flash Gordon. “HA HA HA HA HA HA HA Ha ha ha ha ha…” Sorry, I grew up listening to Queen’s soundtrack from that movie, so every time I hear or write ‘before annihilation’ that line from the movie kicks in. Yes, I know the annihilationist concept of God is very different from that, in theory. Why God would bother resurrecting the wicked and then annihilating them, though, is fortunately not my problem. )