If the contract clearly specified the OP's responsibilities and the facility's responsibilities in writing, so that the OP would have known upon reading it that there was a financial penalty for not completing the contract, I don't think, unfortunately, that the OP really has a basis for saying that they shouldn't have to pay this penalty, if they chose, for whatever reason, to not complete the contract. The OP could seek legal advice.
I agree that some people do not properly understand the full ramifications of a contract, and may not have access to legal advice prior to signing contracts, and I think that is unfortunate.
I also agree that workplace conditions are often far from ideal - this is risk one takes when one takes a job - but again, even if the OP was experiencing this and was unable to or chose not to try to resolve the situation with their employer, and decided to leave because of this, which is their right, they still agreed via the contract to pay back a specified amount of money if they didn't remain with their employer for x amount of time.
I'm not saying that I think the situation was fair, or that the OP doesn't have reason to feel aggrieved about it, or that naivetee doesn't make one vulnerable to not fully understanding what a contract entails, just that, as I understand it, the OP incurred responsibility due to their decision to sign the contract.
I think the lesson for the future is to: 1) Be very careful about what one signs; 2) Ensure one fully understands the ramifications of a contract and the consequences for non-completion for any reason, and 3) Prior to signing a contract, forsee the worst case scenario, I.e. feeling one needs to leave the employer prior to completing the contract.