Literally, a viceroy is someone who rules a country or province as the direct representative of a monarch, acting “in place of the king”. The word originates from the Latin prefix vice- (“in place of”) and the Old French word roy (“king”).
https://www.britannica.com/topic/viceroy-government-official
The term was historically used for officials appointed by a sovereign to govern distant territories—such as the Americas or India—on their behalf, wielding supreme executive authority in that region while answering only to the crown.