A viceroy is appointed by a king to be in charge of a country or province.
When a country is ruled by a monarch — a king or queen — and controls colonies or provinces, the monarch can’t govern all those remote areas personally. That's where a viceroy comes in. The king or queen appoints a representative to rule over the colony or province. This viceroy is the most powerful person in this region, kind of like a king or president. The difference is that the viceroy has to answer to the monarch, his boss back in the mother country.