Yagnavalkya came to Ganaka Vaideha, and he did not mean to speak with him. But when formerly Ganaka Vaideha and Yagnavalkya had a disputation on the Agnihotra, Yagnavalkya had granted him a boon, and he chose (for a boon) that he might be free to ask him any question he liked. Yagnavalkya granted it, and thus the King was the first to ask him a question.
In plain words: Yagnavalkya comes to King Janaka planning to stay quiet. But long ago, after a debate about the fire ritual (Agnihotra), he had granted the king the right to ask any question he liked. So the king asks first.