The function of the practice is to:
Reduce selfish attachment.
Increase a sense of renunciation.
Purify karma by giving and helping develop and expand loving-kindness and bodhicitta.
The practice of Tonglen involves all of the Six Perfections:
Giving, ethics, patience, joyous effort, concentration and wisdom.