You are able to sell your property while it is being leased, but any potential purchaser must be told there is a current lease in place and that the property will not be sold with vacant possession.
The tenant has the right to occupy the residence until the end of the lease term, unless both parties negotiate and agree to terminate the existing agreement.
In some cases, the fact your property has reliable tenants in place may actually be appealing to prospective investors.