What is travel insurance?

Is travel insurance mandatory?

When is the best time to buy travel insurance?