Hi, thanks for submitting your question today. Assuming the contract is sufficiently clear- that you would have to repay it if you failed to stay the three years, there isn't any law or legal precedent that would hold this contract unenforceable.
But let's discuss a practical remedy in this matter. In a similar case to your's, where a client of mine owed a significant relocation because he similarly didn't work a specific period before quitting, he didn't pay after he quit, and the employer sued him for it. Ultimately the employer settled for much less than that amount and a payment plan...not because there was a legal defense to it but because the cost to litigate reduced their net recovery on kind.
Because of the economics of litigation (the costs for attorney, filing etc), I believe you similarly could force the employer to accept less and over a longer period of time (than immediately due) if you wish. It could even be that they do not pursue the matter. The overall point being that you cannot be forced to repay them absent being sued; unless you just want to comply. My overall point though is, because you are in control of your money and whether you decide to pay, you do have some leverage in the matter to void the debt. If you think about it you have nothing to lose in this approach, and they're not going to budge on the debt absent you causing them some reason to think about the economics of their position in the matter.
I believe this answers your question. However, if you need clarification or have follow-up questions regarding this matter, I will be happy to continue our conversation – select the Reply to Expert or Continue Conversation button. If you are otherwise satisfied with my response, please leave a positive rating as it is the only way I am able to get credit for my answers. Thank you, XXXXX XXXXX wish you all the best with this matter.