Thus says the Lord of hosts, the God of Israel, to all who are carried away captives, whom I have caused to be carried away from Jerusalem to Babylon:
Build houses and settle, plant gardens and eat their fruit. Take wives and beget sons and daughters, and take wives for your sons and give your daughters to men, and they shall bear sons and daughters; become numerous there and do not diminish. And you shall seek the peace of the city where I have caused you to be carried away captives, and pray to the Lord for it; for in its peace shall you have peace. (Jeremiah 29:4-7)
Rabbi Chanina, the deputy Kohen Gadol, says: Pray for the welfare of the government, for without the fear [of the government] a man would swallow fellow alive. (Talmud - Avos 3:2)
Rabbi Samson Raphael Hirsch (d.1888) writes (Horeb ch. 96) that we learn from from these verses in Jeremiah that “in whichever land Jews shall live as citizens, as inhabitants, or enjoying special protection, they shall honor and love the princes and Government as their own, contribute with every possible power to their good, and fulfill all the duties towards prince and land which a subject owes to his prince, an inhabitant to his land, and a citizen to his country.”
“This duty is an unconditional duty and not dependent upon whether the State is kindly intentioned towards you or is harsh.”
Indeed, it should be noted that Jeremiah was speaking to people who had been forcibly exiled from their land and taken to Babylonia against their will. Even under such conditions, they were still obligated to "seek the peace" of their host country. As Rabbi Joseph Breuer (d.1980) notes, in his commentary on Jeremiah, “God requires the golah (exiled community) to help promote, with selfless devotion, the welfare of the foreign land in which they dwell. The exiles are bidden to perceive their own welfare as so closely linked with that of their host nation that they will pray to God for a nation that has dealt them the most grievous wounds.”
Similarly, the commentators on Avos (Ruach Chaim, L'Zeicher Yisrael, R' Hertz) note that Rabbi Chanina lived at a time shortly before the destruction of the second Temple, when the Jewish people were under oppressive Roman rule, and was instructing his fellow Jews to nevertheless pray for the welfare of the Roman government. In his commentary on Avos, Rabbi Marcus Lehmann (d.1890) stresses this point:
There are, of course, governments that hardly live up to the ideal--governments that allow arbitrary judgments to take the place of the law, that show preference to some classes of citizens at the expense of others, governments whose executive organs are corrupt. Should the Jew be an obedient citizen to a corrupt government?
Rabbi Chanina lived under such a government. The Roman hegemony was cruel, corrupt, and tyrannical, yet he taught his disciples to pray continually for its welfare because even an unfair and despotic government is a thousand times better than anarchy and no government at all.
If we are obligated to be loyal and patriotic citizens even in lands in which we are oppressed, then how much greater is our obligation towards a country which has always treated us with great kindness! Every day that we live in the United States our obligation of hakaras hatov – gratitude – to the United States increases to higher levels. In 1976 Rabbi Shimon Schwab (d.1995) wrote an essay regarding the American Bicentennial. In this essay he states, in part:
[T]his Bicentennial year gives us a welcome opportunity to express our Jewish gratitude to this nation which has opened its gates to receive millions of us. Jews from all over the globe, who otherwise might have perished in the hell holes of the old world. Here we have found, during the last centuries, a haven of refuge free from pogroms, expulsions, crusaders, inquisitions, concentration camps and gas chambers. The only country where Jews were never burned at the stake or perched in ghettos and where they were not made to wear a badge of shame. Here in America, the Books of the Torah were never burned or censored, and the freedom to teach and practice the laws of G-d was never curtailed or questioned.
… [T]his country has the immense זכות (merit) to be the host to hundreds of thousands of Torah Jews who enjoy the freedom the serve השי"ת (God) without restrictions. All this imposes upon us an ever mounting debt of gratitude which we repay by loyalty to and concern for this nation and by the strict adherence to the laws of the land (דינא דמלכותא).
Such gratitude is of course in reality directed to the Ruler over all nations who permitted us to find shelter and a haven of opportunity in these United States for the welfare of which we pray and whose peace we seek. (Selected Writings, ch. 33)