The devil enticed them..
When Allah Almighty gave dominion to Pharaoh, he thought he was its real owner, so he acted arrogantly and tyrannically and oppressed people. He even attributed to himself the dominion and divinity.
{And Pharaoh said: “O eminent ones, I have not known you to have a god other than me...}
[Surat al - Qasas: 38]
Thus, Allah Almighty destroyed him and made him an example and a lesson for all kings on earth till the Day of Resurrection so their authority would not make them forget their reality and weakness and the Day of Judgmen
Although kings have a semblance of dominion in worldly life, as they possess estates, palaces, gardens, gold and silver, they inevitably have one of two choices: either their possessions will go away and leave them, or they themselves will pass away. Indeed, their kingdom is a transient one, a loan to be paid back.
So, Allah Almighty reminds them that they will ultimately return to Him:
{...And to Allah belongs the dominion of the heavens and the earth, and to Allah is the destination.}
[Surat al-Mā’idah: 18]
Also, the Prophet (may Allah’s peace and blessings be upon him) forbade using the title “king of kings” for any human being. He said:
“The meanest name in the sight of Allah is a man calling himself the king of kings.”
[Narrated by Al-Bukhāri and Muslim]