Habakkuk begins with the prophet asking God how he can allow evil to grow unchecked in Judah and not do anything about it.
God replies that he is bringing in foreign invaders to judge the Israelites. The Chaldeans will take them away into exile.
But, since Habakkuk is sure the Chaldeans are wicked too, he asks how this can satisfy God’s righeousness.
God’s answer involves more than one element. But the one I want to point out, because it is too often missed, is postmillennialism.
(The term is based on a thousand year period mentioned in the beginning of Revelation 20. Some insist it is a future age that occurs through a group of miracles. It occurs after the return of Jesus but before the Last Judgment. But many take it as the era of Gospel preaching that we are in now, but which will grow into a worldwide conversion to the Gospel.)
Habbakuk, I believe, vindicates God on the basis that postmillennialism is true. God will convert the world.
Basically, God says that he will bring about glorious results through the Chaldeans and the exile–results that will means the eventual salvation of both Israelites and the Gentiles:
Woe to him who builds a town with blood
and founds a city on iniquity!
Behold, is it not from the LORD of hosts
that peoples labor merely for fire,
and nations weary themselves for nothing?
For the earth will be filled
with the knowledge of the glory of the LORD
as the waters cover the sea (Habakkuk 2:12-14 ESV).
As I’ve pointed out elsewhere, Paul has to defend the Gospel and God’s character because it means that God used Israel’s sin to bring about the salvation of the world. But the fact that the world is indeed going to be saved is part of his argument that God is justified in his working. (Note, this salvation will be manifest in the eventual conversion of the planet’s population; I’m not saying that past and current unbelievers were saved.)
Paul begins his argument in Romans (1.16-17) with a quotation from Habakkuk. He does this because, like Habakkuk, Paul is arguing that God’s righteousness has been demonstrated. The argument in Romans and Habakkuk work closely together. In Romans we find it repeated: God proves himself righteous in bringing salvation to the world–meaning that this is the age in which the planet (and all other human colonies in space if any) will be converted to Christ.
For we hold that one is justified by faith apart from works of the law. Or is God the God of Jews only? Is he not the God of Gentiles also? Yes, of Gentiles also, since God is one—who will justify the circumcised by faith and the uncircumcised through faith (Romans 3:28-30 ESV).
For the promise to Abraham and his offspring that he would be heir of the world did not come through the law but through the righteousness of faith. For if it is the adherents of the law who are to be the heirs, faith is null and the promise is void. For the law brings wrath, but where there is no law there is no transgression. That is why it depends on faith, in order that the promise may rest on grace and be guaranteed to all his offspring—not only to the adherent of the law but also to the one who shares the faith of Abraham, who is the father of us all, as it is written, “I have made you the father of many nations” (Romans 4:13-17b ESV).
But the free gift is not like the trespass. For if many died through one man’s trespass, much more have the grace of God and the free gift by the grace of that one man Jesus Christ abounded for many. And the free gift is not like the result of that one man’s sin. For the judgment following one trespass brought condemnation, but the free gift following many trespasses brought justification. For if, because of one man’s trespass, death reigned through that one man, much more will those who receive the abundance of grace and the free gift of righteousness reign in life through the one man Jesus Christ. Therefore, as one trespass led to condemnation for all men, so one act of righteousness leads to justification and life for all men. For as by the one man’s disobedience the many were made sinners, so by the one man’s obedience the many will be made righteous (Romans 5:15-19 ESV).
As regards the gospel, they are enemies for your sake. But as regards election, they are beloved for the sake of their forefathers. For the gifts and the calling of God are irrevocable. For just as you were at one time disobedient to God but now have received mercy because of their disobedience, so they too have now been disobedient in order that by the mercy shown to you they also may now receive mercy. For God has consigned all to disobedience, that he may have mercy on all. Oh, the depth of the riches and wisdom and knowledge of God! How unsearchable are his judgments and how inscrutable his ways! (Romans 11:28-33 ESV)
Romans doesn’t use the word “all” and “all men” by accident. The promise to Abraham was that, through him, all the families of the earth will be blessed (Genesis 12.3). Paul emphasizes this promise, saying that Abraham was appointed the heir to the whole “cosmos” (literally; Romans 4.13) and was made a father of “many nations” (4.17). The “all men” in Romans 5 is not a slip. It doesn’t represent universalism but it does positively teach postmillennialism and use that promised outcome as the demonstration of God’s righteousness.
The “much more” in Romans 5 means there will be far more saved in the new age than who were condemned in the former age [Edit: see first comment; I probably overreached here]. And all this is built into the climactic end of Paul’s argument, that God will have mercy on all.