According to the Book of Mormon, the purpose of life to find joy:
2 Nephi 2:25
Men are, that they might have joy
By nature, humans are miserable creatures:
Mosiah 3:19
For the natural man is an enemy to God, and has been from the fall of Adam, and will be, forever and ever, unless he yields to the enticings of the Holy Spirit, and putteth off the natural man and becometh a saint through the atonement of Christ the Lord, and becometh as a child, submissive, meek, humble, patient, full of love, willing to submit to all things which the Lord seeth fit to inflict upon him, even as a child doth submit to his father.
Jesus said that we can find joy through obtaining and living the gospel:
John 7:17, AMP
If any man desires to do His will (God’s pleasure), he will know (have the needed illumination to recognize, and can tell for himself) whether the teaching is from God or whether I am speaking from Myself and of My own accord and on My own authority.
Mosiah 2:41 also teaches the same thing:
The blessed and happy state of those that keep the commandments of God. For behold, they are blessed in all things, both temporal and spiritual; and if they hold out faithful to the end they are received into heaven, that thereby they may dwell with God in a state of never-ending happiness
In summary, the purpose of life is to have joy. The only way to have meaningful joy is to obtain and live the gospel.