Home insurance is not required by law, but all mortgage companies absolutely impose you to have homeowners insurance coverage, otherwise they will not finance your home.
It's a security measure for them to recover their money in case your home burns down or in case of other disasters.
If you live in an area subject to floods the mortgage lender will probably require you to purchase a flood insurance, that is not usually included or bundled with a standard home insurance.
You're not required to have home insurance if you do not have any mortgage, but you should really consider buying it: if you do not have a home insurance you would be paying for every repair, or worse for a full reconstruction.
There's no need to say that probably you could not afford to rebuild your house.
A homeowners insurance will also pay for living expenses you should sustain while your house is being repaired: hotel and other expenses until you can go back to your house.
Purchasing a home insurance policy is a smart choice, you'll always wish that you'll never need to use it, but it's worth the feeling of knowing that, even in case your home received major damages, you'd be backed by your insurance.
If someone accidentally hurts on your property you might be brought to court: you would have to pay for their medical care and provide them income while they're recovering. Home insurance will cover this case too.
In conclusion, home insurance is not required by law, but you should really consider purchasing one, the benefits you might have from it are enormous if compared to how much it will cost you.