"All of your (Pharaoh's) slaves will come down to me and bow to me" (Shemos 11:8). Moshe gave honor to royalty (as Hashem instructed, see Rashi 6:13); even though in the end Pharaoh himself came down to him (12:31), Moshe did not say to him 'You will come down to me and you will bow to me' (Rashi. See Rashi 5:3). The Gemara (Menachos 98a) derives from here that one should always have awe for royalty. Rashi adds that one should not rebel against royalty, and should thank the government for its services.
Another source for "aimas hamalchus - fear/awe of the government" cited in the Gemara is, "the hand of Hashem was with Eliyahu and he...ran before Achav until near Yizre'el" (Melachim I, 18:46.) In order to give honor to royalty, Hashem gave Eliyahu a supernatural strength to run before Achav's chariot so that Achav should not be alone (Rashi).
Chazal chose two of the worst kings to emphasize that we must honor even the vilest rulers. Pharaoh killed our sons and oppressed our people (Shemos 1:13, 22), and is called Pharaoh harasha (the wicked) (Shemos Raba 8:3) for his hubris and depravity. Achav is called the worst of all the bad kings (Melachim I 16:30, 21:25), was a murderer (21:19, see Metzudos) and has no portion in the world to come (Sanhedrin 102b).
Given Hashem's omnipotence and promised intervention, His command and enabling of honor to royalty obviously cannot be attributed to utilitarian motives (shtadlanus), rather it is clearly a more fundamental requirement. Monarchs and leaders serve as Hashem's agents in history, as we are taught, "The heart of a king is in the hand of Hashem" (Mishlei 21:1.) Perhaps this role played by governmental leaders demands a modicum of respect, even in the case of a totally evil monarch.
Alternatively, even the most wicked kingdom may have some redeeming quality. "Do not despise an Egyptian, because you were a stranger in his land" (Devarim 23:8.) Even though they killed your sons, don't despise them forever, since you were saved there from hunger. They honored your patriarch and appointed a ruler from his progeny (Ramban). Similarly, although Achav was the prototype of an evil Jewish king, Achav supported Torah scholars from his royal treasury and was granted partial atonement (Sanhedrin 102b). Furthermore, in Achav's time, the Jews were victorious at war even though they were idolaters because they were not informers (Yerushalmi Peah 1:1). And, in fact, Achav ultimately repented (Melachim I 21:29).
Pharaoh and Achav are paradigms for wicked non-Jewish and Jewish kings respectively, and yet Hashem unambiguously required that we respect them. All the more so in America, the kingdom of kindness, we must recognize all the good received from the government, and bless the State and all of its leaders (Igros Moshe Choshen Mishpat vol. 2, 29). Recent attacks on President Trump are inconsistent with Hashem's command to give honor to non-Jewish royalty. His policies and personal failings do not even begin to approach those of Pharaoh harasha, who Hashem commanded Moshe to honor.
Today's Israeli government supports Torah scholars from its treasury, and the Israeli Defense Forces protect all of Israel's inhabitants from enemies that want to destroy us. Whatever faults exist among Israel's leaders are far less serious than those of the idolatrous murderer Achav. Recent attacks on the government's leaders and soldiers are inconsistent with Hashem's command to honor a Jewish government.
As we read of the honor accorded to wicked kings by Moshe and Eliyahu, we must apply the Torah's timeless lessons to our own generation. If we do so, and especially if we eliminate the terrible sinas chinam resulting from attacks inconsistent with Hashem's command to honor the government, we will hopefully be able to honor the righteous king, Mashiach ben David, speedily in our days.
More divrei Torah, audio and video shiurim from Rabbi Willig