The Quran says that Allah created death and life in order to test which of you is best in conduct, and that every soul will taste death, and you will be given your full reward on the Day of Resurrection. It describes the life of this world as play, pageantry and boasting, like the rain that makes plants grow and then they dry out. In another place it calls the home of the Hereafter the real life. From the Islamic view, if this life were all that there is, the question you ask would be hard to answer. Because it is not all, the question is answered at once: our choices matter, since they last.
Islam also holds that some good does not end with death. The Prophet ﷺ said that when a person dies their deeds come to an end except three: ongoing charity, knowledge from which people benefit, and a righteous child who prays for them. A tree planted, a well dug, a student taught or a book written continues. He described life as the journey of a stranger or a traveller, which gives meaning to the journey itself and not only to the destination.
Many people who do not believe in an afterlife find meaning in love, family, work and helping others, and these are real goods that Islam also recognises. Muslims would add that those goods can carry more weight if they are part of something that outlasts a few decades, and that the deep wish for justice, for love that does not end and for answers is something worth taking seriously. If this question is troubling you, you could read the Quran's own answer to it, starting with the chapters on creation and the Day of Judgment, and judge for yourself.