Indeed life has a great purpose. And that’s to represent Divine beauty by reaching perfection. Death according to Islam is not the end of life but rather a transition from lower type of a life to another.
Challenges in life are very unpleasant, however they are there to equip us with mechanisms to realize the goals of life which was stated above. Therefore, do not get discouraged. Every challenge is a learning curve.