Both the swallow and the Happy Prince, who is now a statue, share compassion for the poor, and this becomes the basis of their friendship.
The swallow plans to spend one night sleeping on the Happy Prince statue before heading off to Egypt to meet his fellow swallows. However, when the Happy Prince's tears fall on him, the swallow gets into a conversation with him. He learns the prince is unhappy because of the suffering and poverty that he witnesses in the city--when alive, he had been sheltered from knowledge of this pain. He asks the swallow to help him tend to the poor.
The swallow keeps meaning to leave the city, but the needs of the poor don't go away. Therefore, he and the statue form a partnership. The swallow, at the statue's request, strips away the statue's jewels and gold and delivers them in bits to the poor as the statue directs. This way, the two of them alleviate much suffering in the city.
Both have generous hearts and put others' needs ahead of their own. Both earn a place in heaven.