David's reaction to the loss of his child offers a profound perspective on the boundaries of prayer and the nature of grief. As long as a life hangs in the balance, there remains a space for hope and spiritual effort, but once death is final, the time for pleading comes to an end.
The primary approach among commentators is that David's intense fasting and weeping were not merely expressions of sorrow over his son's illness. Rather, they were an active form of prayer, a deliberate effort to beg for the child's recovery. David operated on the principle that it is appropriate to pray only for outcomes that are still possible, rather than situations that are irreversible. While the child was still breathing, David held onto the thought that the decree of death might not yet be sealed, leaving a window of opportunity for rescue [מצודת דוד]. He hoped that God would act toward him with grace and mercy, ultimately leading to the child's complete recovery from his sickness [ביאור שטיינזלץ].
However, the moment the child passed away, the purpose of these prayers instantly expired. It is understood that one does not pray for the dead to return to life. Furthermore, a clear distinction is made regarding the different ways David experienced grief. When his adult sons, Amnon and Avshalom, died, David wept out of pure, deep sorrow for their loss, with no expectation of bringing them back. Mourning an infant, however, is fundamentally different. Because a baby has not yet developed into a person of mature understanding, the loss does not warrant the same intense level of mourning and weeping that follows the death of a grown adult [רד״ק]. Consequently, once all hope for the child's healing was gone, David immediately rose from his mourning and moved forward.