Double Chastisement (Payment/Recompense) for Jerusalem's Sins
The prophetic cry of Isa 40:1-2 follows Isaiah's declaration to Hezekiah about the coming judgment from Babylon in Isa 39:5-7 (NKJV):
5 Then Isaiah said to Hezekiah, “Hear the word of the LORD of hosts: 6 ‘Behold, the days are coming when all that is in your house, and what your fathers have accumulated until this day, shall be carried to Babylon; nothing shall be left,’ says the LORD. 7 ‘And they shall take away some of your sons who will descend from you, whom you will beget; and they shall be eunuchs in the palace of the king of Babylon.’”
While this prophetic judgment was in response to Hezekiah's opening the palace for Babylonian inspection (39:1-4), Hezekiah is (smugly?) pleased that it is not coming in his days (39:8).
But following the prophecy of judgment by Babylon and Hezekiah's reaction, Isaiah at some point (it may not have been immediately then) also gave this prophecy of comfort in chapter 40, which also declares the extent of Jerusalem's payment to be "double for all her sins."
Fast-forward to Jeremiah's day, when things are rapidly approaching this fulfillment of Babylon's conquest. Jeremiah gives a specific prophecy about a time frame in Jer 25:11-12
11 And this whole land shall be a desolation and an astonishment, and these nations shall serve the king of Babylon seventy years.
12 ‘Then it will come to pass, when seventy years are completed, that I will punish the king of Babylon and that nation, the land of the Chaldeans, for their iniquity,’ says the LORD; ‘and I will make it a perpetual desolation
The key here is the seventy years the "land shall be a desolation."
1 The beginning of this comes to pass in Jeremiah's day with Babylon's destruction of Jerusalem in 586 B.C., but as learned in the book of Haggai, the land does not start producing again until the completion of the Temple has been done (Hag 2:15-19), which is in 516 B.C. (70 years).
But though the Temple is done, Jerusalem itself is still uninhabited until the rebuilding of the walls by Nehemiah, which is another 70 years later, in 445 B.C., and so double the amount of time that the rest of the land of Israel.
Isaiah's prophecy was thus of Jerusalem having to lay desolate for twice the time of the rest of the land for her sins, but in his prophecy, that payment time is past (hence the comfort), and so Israel is to be looking then for the one noted in Isa 40:3, the coming of the one preceding the coming of the LORD himself:
The voice of one crying in the wilderness: “Prepare the way of the LORD; Make straight in the desert A highway for our God.
Iniquity is pardoned, their God is coming—take comfort.
[P.S. I have more I want to add in details above, but no time now, so I'll have to come back to it.]
1 The 70 years of the land is a different period from the 70 years of service to the king of Babylon. The land's desolation, as discussed above, is from 586 B.C. (destruction of Jerusalem) to 516 B.C. (completion of 2nd Temple), while the service is from 605 B.C. (the 1st deportation to Babylon) to 535 B.C. (the return by Zerubbabel and the laying of the 2nd Temple's foundation).