You probably have a contingency in the contract that says the property needs to appraise at the sale price. If the bank requires repairs in order for them to accept the appraised value, then in essence, the house is not worth the sale price in the condition it now stands and therefore the contingency that the home appraise for the sale price is not met. That being said, depending on the wording of the sales contract, you should be entitled to your earnest money if you decide not to make the repairs.
Information I provide in this forum is not legal advice. The information provided is only general information that may or may not apply to you and may or may not be based on current law. I am NOT YOUR attorney. For specific legal advice you need to contact an attorney and enter into a retainer with that attorney.
It all depends on what the contract says; many contracts provide for an appraisal contingency. Newer forms commonly used do not. It is hard to say what you have. If the earnest money is significant, it may be worth hiring a lawyer to help.......he can help to get some of it back, anyway.