The Cariyāpiṭaka is a less-read and less-translated portion of the Khuddaka Nikaya, the same collection that holds the Dhammapada. The Cariyāpiṭaka is another collection of past lives of the Buddha; as always, these are teaching stories, meant to illustrate the kind of behavior that will lead you toward — or away from — enlightenment.
In this verse, the great king Mahasuddasana explains how his lavish giving was a form of spiritual healing for him:
“Yathāpi āturo nāma, rogato parimuttiyā.
Dhanena vejjaṃ tappetvā, rogato parimuccati.
“Tathevāhaṃ jānamāno, paripūretumasesato.
Ūnamanaṃ pūrayituṃ, demi dānaṃ vanibbake.
nirālayo apaccāso, sambodhimanupattiyā”ti.
Just as one who is ill, wishing to be surely free of disease,
Gives enough money to the doctor, and is freed from sickness,
Knowing this truth, for complete, remainder-less liberation,
To fill a wanting mind, I gave food to the poor wayfarers,
To the homeless children, to gain the mind of complete enlightenment.
Mahāsudassanacariyā, Cariyāpiṭaka 1.4