Title insurance protects against problems with the property's title — undisclosed heirs, forged documents, recording errors, unpaid liens — that could threaten your ownership. There are two policies: a lender's policy (protects the lender, required) and an owner's policy (protects you, optional but strongly recommended).
Premiums are paid one-time at closing and last as long as you own the home. Rates are regulated state by state — in many states the cost is fixed, in others you can shop. Either way it's typically the largest single closing-cost line item after origination.
Skipping owner's title insurance is rarely worth the savings. A bad title problem can cost tens of thousands to defend. The owner's policy is usually a few hundred dollars on top of the lender's policy at closing.