How does granting interim bail on medical grounds balance individual rights and the justice system's needs?

The Supreme Court recently granted interim bail to Mahesh Raut in the Elgar Parishad-Maoist links case due to his health condition. I want to understand how courts decide between a person's health rights and the requirements of an ongoing investigation or trial.