karmanaiva hi samsiddhim
sampasyan kartum arhasi
Kings such as Janaka attained perfection solely by performance of prescribed duties. Therefore, just for the sake of educating the people in general, you should perform your work.
Commentary by Srila Prabhupada
Kings like Janaka were all self-realized souls; consequently they had no obligation to perform the prescribed duties in the Vedas. Nonetheless they performed all prescribed activities just to set examples for the people in general. Janaka was the father of Sita and father-in-law of Lord Sri Rama. Being a great devotee of the Lord, he was transcendentally situated, but because he was the king of Mithila (a subdivision of Bihar province in India), he had to teach his subjects how to perform prescribed duties. Lord Krishna and Arjuna, the Lord’s eternal friend, had no need to fight in the Battle of Kurukshetra, but they fought to teach people in general that violence is also necessary in a situation where good arguments fail. Before the Battle of Kurukshetra, every effort was made to avoid the war, even by the Supreme Personality of Godhead, but the other party was determined to fight. So for such a right cause, there is a necessity for fighting. Although one who is situated in Krishna consciousness may not have any interest in the world, he still works to teach the public how to live and how to act. Experienced persons in Krishna consciousness can act in such a way that others will follow, and this is explained in the following verse.
Commentary by Sri Visvanatha Cakravarti Thakur
He gives proof of such actions in the first part of the verse. In the second part of the verse he says that if you think that you are qualified for jnana, even then, you should perform action it order to teach the people.