The law of habitability primarily protects renters. It is what makes maintenance of the property the responsibility of the landlord, who must comply with building and health codes that, in aggregate, define habitability. The failure to keep a property in a habitable condition gives the renter the right to withhold rent from the landlord until the condition is remedied.
The law of habitability is not a written statute. Instead, it's what is called an implied warranty. In other words, the law assumes that when someone who rents or leases a property to someone else for the purpose of dwelling in it, the party signing the lease can reasonably assume the dwelling is habitable. Habitability does not necessarily apply to the sale of property, which can be transferred in any existing condition.
The basic requirements of habitability are that the building must be structurally sound, sanitary, and must provide protection from the elements (weatherproofing). It must also have access to heat, water, sewage, and electricity, though the landlord is not required to provide these actual services. There is no precise, universal definition for habitability, though state and local codes are likely to provide the most complete standard for any particular area.
In addition to the features listed above, habitability is usually interpreted to include a functioning and effective lock on the front door and operational smoke detectors. The presence of some bugs does not render a building uninhabitable, but a significant infestation might. Also, the conditions of the grounds and surrounding area can affect habitability, such as if there is a septic tank leak or toxic waste in the yard.
If a property is uninhabitable, or becomes uninhabitable during the course of a lease, the tenant has the right to withhold rent until the premises are rendered habitable. The major exception is that the landlord is not responsible for damage caused by the tenants or their guests. Otherwise, a landlord has the obligation to ensure the property complies with all state and local building and health codes.
If a tenant believes the property he is renting or leasing is uninhabitable and that the landlord is responsible, he should contact the local housing or safety board as soon as possible. Withholding rent is an option, but state laws usually require the landlord to be given adequate notice of the tenant's intention to take this course. The better the tenant is able to document the conditions the better chance she has of protecting themselves in a suit for unpaid rent by the landlord.