This actually hasn't always been the case.
In fact Hospitals were not required to treat you until 1986, which was part of the COBRA act.
Prior to that there was a large practice of "Patient Dumping" where a hospital would kick you out if they found out they you couldn't pay for your treatment. Hospitals in the US would literally let you die out side the ER doors.
https://en.wikipedia.org/wiki/Emergency_Medical_Treatment_an...