Why does Whitman believe that death has a purpose?
For Whitman, life and death are inextricably intertwined in a huge circle. One thig dies, another is born. The purpose of death is to keep the circle moving. Death is not something to be feared, rather embraced as your role in the eternal circle. We should enjoy life while we have it, to the fullest, Whitman argues, but it is not a gift we get to keep. It must be passed along. The circle must not be broken. Accept your coming role with grace and dignity.
Here are two quotes that might help you understand his thinking about the purpose of death:
1) "I announce the great individual, fluid as Nature, chaste, affectionate, compassionate, fully armed; I announce a life that shall be copious, vehement, spiritual, bold, And I announce an end that shall lightly and joyfully meet its translation."
2) "I see Hermes, unsuspected, dying, well-beloved, saying to the people, “Do not weep for me, This is not my true country, I have lived banished from my true country — I now go back there, I return to the celestial sphere where every one goes in his turn.”