A landlord may legally terminate a lease if a tenant significantly violates its terms or the law -- for example, by paying the rent late, keeping a dog in violation of a no-pets clause in the lease, substantially damaging the property, or participating in illegal activities on or near the premises, such as selling drugs.
A landlord must first send the tenant a notice stating that the tenancy has been terminated. State laws set out very detailed requirements as to how a landlord must write and deliver (serve) a termination notice. Depending on what the tenant has done wrong, the termination notice may state that the tenancy is over and warn the tenant that he or she must vacate the premises or face an eviction lawsuit. Or, the notice may give the tenant a few days to clean up his or her act -- for example, to pay the rent, or to find a new home for the dog.
If the tenant fixes the problem or leaves as directed, no one goes to court. If a tenant doesn't comply with the termination notice, the landlord can file a lawsuit to evict the tenant. For more information, see Nolo's article How Evictions Work: Rules for Landlords and Property Managers.
For a comprehensive legal and practical guide for landlords, see Every Landlord's Legal Guide, by Marcia Stewart, Ralph Warner, and Janet Portman (Nolo).