This is how I heard. At one time, the Blessed One was staying in the province of Rājagaha in the Bamboo Garden, the Squirrels’ Reserve. There the Blessed One addressed the monks saying, “ Oh monks.” “Bhante,” those monks replied to the Blessed One.
“Monks, a long time ago, in this same province, there was a very poor and helpless beggar. He practiced faith, virtue, Dhamma learning, generosity, and wisdom in the path proclaimed by the Buddha. Having practiced faith, virtue, Dhamma learning, generosity, and wisdom in the path proclaimed by the Buddha, after death, at the breakup of the body, he was reborn among the Tāvatiṁsa gods. He outshone the other gods in regards to beauty and glory.
“Then monks, the Tāvatiṁsa gods became annoyed with him, criticized and insulted him saying, ‘It is wonderful indeed sirs! It is amazing indeed sirs! For before he became a god, he was a poor helpless beggar. After death, at the breakup of the body, he was reborn among the Tāvatiṁsa gods, and now he outshines the other gods in regards to beauty and glory.’
“Then, monks, Sakka, lord of the gods, told the Tāvatiṁsa gods: ‘Dear sirs, don’t insult this god. In the past, this young god was a human being. He practiced faith, virtue, Dhamma learning, generosity, and wisdom in the path proclaimed by the Buddha. Having developed faith, virtue, Dhamma learning, generosity, and wisdom in the path proclaimed by the Buddha, after death he was reborn among the Tāvatiṁsa gods. He now outshines the other gods in regard to beauty and glory.’
“Then, monks, Sakka, lord of the gods, recited these verses, making the Tāvatiṁsa gods happy:
“‘When one has unshakable, well established faith in the Supreme Buddha and good virtue, praised by the noble ones;
“‘When one has confidence in the community of monks and one understands the Dhamma, they say that one isn’t poor; his life is not meaningless.
“‘Therefore the wise person, remembering the Buddha’s teachings, should be devoted to faith, virtue, confidence and realization of the Dhamma.’”