וַיֹּאמֶר אֲלֵהֶם חָטָאתִי הַפָּעַם יְהוָֹה הַצַּדִּיק וַאֲנִי וְעַמִּי הָרְשָׁעִים "And [Pharaoh] said to them, I have sinned this time, G-d is the Righteous One and I and my people are the wicked ones" (Shemoth 9:27). Pharaoh shows contrition over having denied the existence of G-d and the failure to listen to His commandments. Very soon thereafter, however, the Torah tells us, וַיֹּסֶף לַחֲטֹא וַיַּכְבֵּד לִבּוֹ הוּא וַעֲבָדָיו "And he sinned further and hardened his heart, he and his servants" (Shemoth 9:34).
Rabbenu Bahyei writes that when the wicked face difficulties they become humble, but only temporarily. The moment their tribulations disappear, they revert to their wicked ways. We see this clearly in the case of Pharaoh who exclaims to Moshe Rabbenu (Moses), 'a"h, that he has sinned against G-d, but as soon as the plague of hail and thunder abated, he immediately reverted to his evil ways. However, this arrogance on the part of the wicked is what causes their demise. Rabbenu Bahyei says that it is on account of this arrogance, of claiming not to know who G-d is, that Pharaoh perished in the Red Sea.
The righteous, however, practice humility. Contrary to the belief of the wicked, it is the humility that the righteous practice, that brings them their glory.
(See Rabbenu Bahyei on the Torah, Shemoth 9:27, 34)
Vaera, Waera, Parasha Righteous and arrogant, Par'oh, Pharaoh