Sanhedrin2: 2
הַמֶּלֶךְ לֹא דָן וְלֹא דָנִין אוֹתוֹ. לֹא מֵעִיד וְלֹא מְעִידִין אוֹתוֹ. לֹא חוֹלֵץ וְלֹא חוֹלְצִין לְאִשְׁתּוֹ. לֹא מְיַבֵּם וְלֹא מְיַבְּמִין לְאִשְׁתּוֹ. רַבִּי יְהוּדָה אוֹמֵר: אִם רָצָה לַחֲלוֹץ אוֹ לְיַבֵּם, זָכוּר לְטוֹב. אָמְרוּ לוֹ: אֵין שׁוֹמְעִין לוֹ. וְאֵין נוֹשְׂאִין אַלְמְנָתוֹ. רַבִּי יְהוּדָה אוֹמֵר: נוֹשֵׂא הַמֶּלֶךְ אַלְמְנָתוֹ שֶׁל מֶלֶךְ, שֶׁכֵּן מָצִינוּ בְדָוִד שֶׁנָּשָׂא אַלְמְנָתוֹ שֶׁל שָׁאוּל, שֶׁנֶּאֱמַר: ,,וָאֶתְּנָה לְךָ אֶת בֵּית אֲדֹנֶיךָ וְאֶת נְשֵׁי אֲדֹנֶיךָ בְּחֵיקֶךָ”.
The king may not judge nor be judged. He may not testify nor be testified against. He does not perform chalitzah, nor is chalitzah performed with his wife. He does not perform yibum, nor is yibum performed with his wife. R’ Yehudah says: If he wishes to perform chalitzah or yibum, the is remembered favorably. They said to him: They do not listen to him. No one may marry his widow. R’ Yehudah says: A king may marry the widow of [another] king, as we find that David married the widow of Saul, as it is stated: And I gave you the house of your master and the wives of your master in your bosom.