At the beginning of Great Expectations by Charles Dickens, Pip helps a convict escape by bringing him food and a file with which to remove his chains. The convict ends up captured anyway, but he will not implicate Pip.
As the years go by, Pip grows up, and the incident with the convict fades into the past. Pip is surprised to inherit a large fortune from an anonymous benefactor, and he goes rather crazy for a while, spending and acting foolishly with his newly found wealth. But Pip is soon in for another surprise. His benefactor is the very convict he helped so many years before, a man by the name of Magwitch who earned his money in Australia and made a commitment to helping the boy who tried to help him.
Pip is more than a bit horrified at first, but he learns to love Magwitch over time, and he plans Magwitch's escape from London, determined to get him to safety. The attempt fails, and Magwitch ends up in prison. Pip looses his fortune. Yet it is at this point that Magwitch likely helps Pip the most. Pip cares tenderly for Magwitch until the latter dies in prison, and this teaches Pip the value of self-giving love.
Pip also reconciles with his brother-in-law, Joe, who steps up to pay Pip's debts. Pip now has to earn his way in the world, and this, too, is a good thing. He goes into business with Herbert and is successful. Indeed, Magwitch's greatest gift to Pip is not the money (which is lost anyway), but the opportunity to mature and to grow into a decent, caring human being.