There are various answers in various scriptures to this question. In the Bhagavad-gita, we have the verse: paritrāṇāya sādhūnāḿ vināśāya ca duṣkṛtām dharma-saḿsthāpanārthāya sambhavāmi yuge yuge (Bhagavad-gita 4.8). Krsna says here that He appears millennium after millennium to annihilate the demons and to re-establish the principles of religion. In the Srimad Bhagavatam, Kuntidevi is explaining that the Lord appeared because of the austerities carried out by Vasudeva and Devaki and that it was in response to these austerities that Krsna appeared as their son. Other sources say that bhumi was overburdened by military phalanxes and impious rulers, and accordingly went to Lord Brahma to request for Krsna to appear.
Gaudiya vaisnavas however understand that ultimately Krsna appears to reveal His transcendental pastimes from the spiritual world. No other incarnation of the Lord does this, not even Lord Rama, even though Lord Rama is practically non-different from Lord Krsna. Lord Rama appears with the purpose of teaching the example of dharma, however Krsna’s pastimes are simply transcendental and are not bound by any mundane morality. His pastimes are only bound by the love that His devotees exhibit and His desire to increase their love. So it is in this way that we must approach Janmashtami – meditating on how Krsna is bound by the love of His devotees and how He desires to increase the love of His devotees.