In the Bhagavad Gita, The Song of God, the Blessed Lord states the following to Arjuna:
"Though I am unborn and eternal by nature, and though I am the Lord of all beings, yet, subjugating My Prakriti, I accept birth through My own maya.
Whenever there is a decline of dharma, O Bharata, and a rise of adharma, I incarnate Myself.
For the protection of the good, for the destruction of the wicked, and for the establishment of dharma, I am born in every age.
Whoso knows, in the true light, My divine birth and action will not be born again when he leaves his body; he will attain Me, O Arjuna.
Freed from passion, fear, and anger, absorbed in Me, taking refuge in Me, and purified by the fire of Knowledge, many have become one with My Being."
translated by Swami Nikhilananda, Ch. 4, verses 6-10