Firstly, despite it’s popularity over social media, such a statement was never said by Ali, the fourth caliph and son-in-law of the Prophet Muhammad (pbuh), nor anyone else from among the righteous predecessors. It is said to be a statement of Socrates as mentioned by Ibn Qayyim in Ighatha Al-Lahfan and by Shahristani in Al-Milal wa Al-Nahl. It was also said that it is a statement of Plato as mentioned in Lubaab Al-Adaab.
Secondly, the meaning of the statement may be correct if it pertains to virtuous acts that are not legislated in Islamic law. Acts which are not religiously obligated cannot be forced on to the children. For example, if a certain non-obligatory virtuous act is followed in a particular time period but becomes difficult to implement in later times due to change in circumstances, then parents should not force their children to abide by it just because they used to in their days.
However, if it is a religiously obligated virtuous act, then parents have every right to pass it on to their children as much as possible and a change in time will have no effect on its obligation. For example, honesty, trustworthiness, leaving sin, abiding by clear and explicit commands of the Qur’an and Sunnah, etc. will never cease to change with time and place. The righteous predecessors used to learn their behavior from their elders as some of the people of knowledge stated:
“Ibn Mas’ud used to resemble the Prophet Muhammad (pbuh) in his guidance, conduct, and character. ‘Alqamah used to resemble Ibn Mas’ud in these things. Ibrahim used to resemble ‘Alqama, Mansoor used to resemble Ibrahim, Sufyan used to resemble Mansoor, Wakee’ used to resemble Sufyan, Ahmad used to resemble Wakee’, and Abu Dawud used to resemble Ahmad bin Hanbal” (Al-Bidayah wa Al-Nihayah 14/618).
In other words, all of these people learned from their teacher, starting with the Prophet Muhammad (pbuh), who passed it on to his student Ibn Mas’ud and he to his student ‘Alqamah and so on all the way down to Abu Dawud. They passed the same key aspects of guidance, conduct, and character down the generations.