Proverbs 13:22 (ESV)

22 A good man leaves an inheritance to his children’s children, but the sinner’s wealth is laid up for the righteous.

The wise man seeks to do what is good for others especially his children’s children. Since they are part of his family he is concerned about their material wellbeing therefore he will leave his wealth for them as an inheritance. His purpose in showing this generosity to them is that they will have his wealth to provide for their needs. In contrast the sinner’s wealth will not be of benefit for his children’s children because he has squandered it on himself. Instead of it achieving anything good for his family it will be laid up for the righteous. The righteous who are those who trust and obey God will be rewarded with the wealth taken from the sinner. This was the case when at the death of Haman who was king Xerxes right hand man his wealth was passed on to Mordecai and Esther.