As the Holy Prophet was rich, it is certain that on taking over the responsibility for the maintenance of Ali, the Holy Prophet made the best possible arrangement for his education. Later in life, Ali came to enjoy reputation for being the most learned man of his age in Arabia. This points to the fact that the Holy Prophet took particular care in educating Ali, Ali was a precocious child, at an early age he came to master knowledge which others could hardly understand.
"When a person dies, his works end, except for three: ongoing charity, knowledge that is benefited from, and a righteous child who prays for him."
Prophet Mohammed (PBUH)
"The best of what a man leaves behind are three: a righteous child who supplicates for him, ongoing charity the reward of which reaches him, and knowledge that is acted upon after him."
Sunan Ibn Mājah
"Every day two angels come down from Heaven and one of them says, 'O Allah! Compensate every person who spends in Your Cause,' and the other (angel) says, 'O Allah! Destroy every miser.'"
Sahih Bukhari