Let's even leave medical students aside cause as an alternative, they could practice on cadavers or on humans during their training programs.
A lot of drugs and vaccines are first tested on animals to be sure of their efficacy and effects before being administered to humans. Imagine for a moment that these drugs are directly given to humans, and then they cause harm. However, we like to view it. If we are made to choose between a human or animal's life, we would choose the former. And it doesn't mean we are not empathetic towards them. It's just that we have limited alternatives.
But then cadavers are none living and some surgery requires that the patient is alive to be sure it was successful. Also how many humans will all the med students use to practice and what if it goes wrong that means a life has been wasted. 🤷