The lease obligates the new owner (it runs with the land). So, selling the home with it rented means the new owner gets the property with tenants in place until their lease expires.
Some tenants will cooperate in allowing showings with proper notice. Typically, an hour's notice is given, but the tenant may need more time to get home and put up pets. Also, if it's too inconvenient or uncompensated, the tenants may object to being dragged home to put things in order or keep them that way.
Explain to them they're not being booted out - their lease will still run its course. Naturally, some tenants will be apprehensive or just won't clean the place up so it can be shown. In some cases the tenants will actually lock out visitors (in Texas the keyless lock does that). You may have to massage their feelings and accept less than spotless or else you can offer to send a maid in once a month to help them clean up.
Once sold, you or the new owner needs to notify the tenants of the new owner (and new manager if there is a change).
Don't forget about transferring the security deposit to the new owner (and letting the tenant know this).