Liability insurance is insurance that protects you from loss in the event you are alleged to have negligently caused harm or damage to another or are determined to have negligently caused harm or damage to another.
Liability insurance offers two important components. First, liability insurance pays for a lawyer to represent you in the event you get sued for negligently causing someone harm or damage. This is known as the "duty to defend." Second, liability insurance pays any judgment entered against you for negligently causing harm or damage to someone else. This is known as the "duty to indemnify." The amount the insurance company will pay is capped at the amount of liability insurance you have.
There is a liability insurance component in almost every motor vehicle insurance policy. There is also a liability insurance component in your homeowner’s insurance policy. If you run a business, you may have (and should have) a "general liability" insurance policy that protects you for negligent acts and omissions by you or your employees as part of your business operations.
Liability insurance policies often have "exclusions," that is, there are certain acts or omissions it does not cover. For example, liability insurance does not cover the policyholder for intentional acts.
For an example on how automobile liability insurance policies work, read here.