Couple of points to consider here. First is that your first lender, who is paying all your closing costs, will be out thousands of dollars should you refi that loan immediately. Sure he would NEVER have agreed to cover your costs if you told him you had any intention of closing the loan and then paying it off. Your proposed strategy might be legal, but I would certainly not call it ethical.
Secondly, why would you even close first loan if you’re not happy with the appraisal and with the rate? Seems to me there is no reason to do so. Have you asked your first lender about rate renegotiation? Lenders can sometimes work with borrowers when rates move dramatically during the loan process.
Basically, you and your lender should have a partnership. He is providing a service to you as much as a product, and is a professional whose time and expertise are every bit as valuable as your money. When you put a lender through the loan process without being committed to the loan, you’re wasting his resources without compensating him. The time to shop, under most circumstances, is before you commit to the loan, not after.
Lastly, rates haven’t moved nearly as much as you state. PRICING may have changed by 50-75 bps, but not rates. Best execution rates have been in the 3.75% + or – .125% range for some time. If your current rate lock is far above that, right thing to do would be to ask first lender if they can renegotiate to lower rate. If answer is no, and 2nd loan is that much superior, cancel the first loan and close the second.