Whether it is legal in your particular circumstances can be determined only by reviewing the lease agreement. Typically, however, there is no provision for notifying a tenant of a sale, impending, completed or anticipated.
A real estate company (we assume in this case) means a property management company contracted with the true owner to manage the property, is that right? Just be aware that technically the owner can sell the property without telling even the property manager -- it would be dumb, but equally dumb things happen every day. The owner probably has no obligation, either, to notify you of an attempt to sell or the intent to sell or the actual completed sale, but only the lease agreement dictates whether that's true or not.
However, unless provided in the lease, he can't just have people drop by whenever they feel like to view the place as prospective buyers. Besides if they did show up, you would find out quickly that he intends to sell the property. Read your lease to see about having prospective tenants or buyers view the property.
Your lease is an interest in the property and a sale does not automatically terminate your lease. Usually, the lease runs with the sale, meaning it must be respected by the new owner until it terminates of its own accord. If it is a month-to-month lease, the new owner can give you 30 days notice to terminate it. If it still has 33 months to run, then he has to wait 33 months or else wait for you to breach the lease so that he can terminate it.
Don't panic, but you should discuss the matter with the property manager to find out what their intentions are with respect to you. You should also consider having your legal counsel review your lease to make sure your rights are protected in the pre-sale, sale and post-sale events.... more