Public service loan forgiveness (PSLF) exists and a huge number of people in medical professions actually take advantage of it. I know of multiple medical students and residents with over $500k in debt that are in the process of having all of their loans forgiven after 10 years in training and a total cost of approximately $75–150k for their entire education. Sure, that's still a decent amount of money, but it's very much worth the ROI.
https://en.wikipedia.org/wiki/Public_Service_Loan_Forgivenes...