The death of David’s child was indeed mercy. The punishment under the law for David’s actions was death. So David got mercy. Similarly the child would have suffered as an illegitimate son. Ultimately all of us are fallen under God so this is just tho sad.