Lord Krishna says in the Gita that He comes to protect the good, kill the wicked and to establish dharma. Dharma is never destroyed totally. But it is sometimes threatened, when evil people gain the upper hand, and torment the virtuous. At such times, He comes to the rescue of the good. The main purpose of His avataras is to save the good, said M.A. Venkatakrishnan in a discourse. To accomplish this, naturally He must kill the evil ones, and automatically dharma again regains supremacy. That is why He talks of protecting the good first, before He talks of killing undesirable people and re-establishing dharma.
There are four types of people who seek Him, Krishna says. They are as follows: those who have lost their wealth and want to regain it; those who are looking to acquire wealth; those who want to experience the self, and those who surrender to Him, for they seek nothing but the Lord Himself. The last category are jnanis, and Krishna says they are very dear to Him. He says that although all His devotees are important to Him, it is the jnanis who rank the highest.
Protecting such people becomes imperative, when they are threatened, and hence the Lord takes avataras. When He begins the task of protecting the good, those who are ill disposed towards the good are naturally destroyed, just as flourishing rice crops crush emerging weeds and prevent them from spreading. There is a sloka that says that when Rama was born as the son of Dasaratha, the Vedas too arrived, through the words of sage Prachetasa (Valmiki). In other words, through Valmiki, the Vedas appeared as the Ramayana. Equally, it can be said that when the Lord took birth as Krishna, the Vedas appeared as the Vishnu Purana, and as Srimad Bhagavatam.