Ask a landlord-tenant lawyer and get answers ASAP
I'm Lucy, and I'd be happy to answer your questions today. I'm sorry to hear about your situation.
What state do you live in? Also, do you have a lease for a set term or is it month to month?
In that case, yes, he could ask you to move at any time on 30 days notice, including if he were selling the property. It's not illegal to tell you that he's going to sell, then not do it, although I can see why that would be frustrating. The only way to protect yourself would be to sign another lease for a set term. If the landlord happened to sell the property while you had a lease, the lease just transfers to the new owner. It doesn't terminate.
I'm going to get the statutes on the warranty of habitability for you and will be back in a few minutes.