It depends on the context in which the phrase is used.

If you are talking about a specific king, then you would use “the king.” For example, “The king is coming to visit.”

If you are talking about a general concept of kingship or a role that someone might hold, then you would use “a king.” For example, “He wants to be a king.”

“I read a book about a king who ruled a large kingdom.” (In this sentence, “a king” refers to a general concept of kingship and is not specific to any particular king.)

“The king of this country is very popular.” (In this sentence, “the king” refers to a specific person who is the king of a particular country.)

“She was married to a king, but he was not the king of any country.” (In this sentence, “a king” refers to a specific person who held the title of king, but he was not the ruling monarch of any country.)

In the game of chess, the king is the most powerful piece.” (In this sentence, “the king” refers to the specific piece in the game of chess.)

“The king was very pleased with the gift that his subjects gave him.” (In this sentence, “the king” refers to a specific person who is the ruling monarch.)

“She dreamed of one day marrying a king and becoming a queen.” (In this sentence, “a king” refers to a general concept of kingship and is not specific to any particular king.)

I hope these examples help to clarify the difference between “a king” and “the king.”