This is a very poignant question, especially in times like a global pandemic, when thousands of people are dying every day. It strikes at the very root of the concept that God is compassionate.
First, we must understand that Soul, the expression of Life Force within us, is immortal. It is a traveler that is occupying this body temporarily and must move on.
Second, someone may think that death is a punishment, permanent. This is not true. We have come here with an agenda, propelled by our past, and with limited resources, including time. Our time is best utilized when we understand the goal of life, and pursue it with sincerity and devotion. Death is not a punishment. It is a window of opportunity. We will move on to better places, depending on our performance in this and earlier lives.
God IS compassionate. He promises in the Gita–”Na me Bhakta Pranashyathi”. My devotee shall never perish. You take one step closer to me, and I will come 10 steps closer to you.
Then why do all these people suddenly die? We are all sent to this world to learn. Some learn quickly, some take time. All actions must produce results. When and where, we don’t know. Perhaps we have been to places where we should not go or did things we are not supposed to or ate something we are not supposed to. Nature and the Law of Karma enforces the consequences of those actions.
It is only our attachment to this ephemeral body that makes death seem so painful. The Upanishads say that to the Realized Master, death is but a pickle on the tongue, to be enjoyed.
I am not the body. Aham Brahmaasmi. I am that Immortal Reality.
This is true for even those that do not understand it or accept it.
.
Other reading material:
Relevant videos: Swami Nikhilanand Hinduism Q & A: Why Does God Allow Suffering
Contributor: Madhu Kopalle