Depends on who's paying for it. When you buy a home, you can often get the seller to cover a 1- or 2-year home warranty for the basics (structure, roof, plumbing, HVAC). This is usually insurance as much for the seller as the buyer; if something goes wrong that the seller and home inspector thought were fine, the buyer (who must now fix the problem as they've closed on the house) can call on the home warranty, pay the $100 deductible or whatever, and the problem will be fixed. This dramatically reduces the incidence of lawsuits after closure; actual damages no longer include the real cost to fix the problem (which can be in the tens of thousands for something big like rotting timbers in the attic due to a leak).
As far as you as a homeowner buying a warranty for your own home, this is basically supplemental homeowner's insurance, and you should treat it as such.
The thing to remember with any insurance is that it is a bet; in fact, the field of probability mathematics was originally developed for underwriters, not casinos. By buying the policy for X dollars, you are "betting" the insurance company that some catastrophe will befall your home within the term of the policy. The insurance company is betting Y dollars that your house will be in the same condition at the end of the month (or six months or year etc) as it is now, and if they're wrong they'll pay you up to Y dollars to cover the loss. In the case of home warranty, they generally have more individualized limits on payout and more limited coverage, but the idea is the same. These "bets", just like bets against the house in a casino game, are rigged in favor of the insurance company; the "paid odds" (ratio of payoff to policy cost per year) is less than the "true odds" (ratio of probability against versus probability for) that your house will be totaled in any given term of the policy. Supplemental insurance is less tightly controlled by regulation, since you aren't required to have it (unlike basic home insurance, which under certain mortgage contracts you are often required to have), which means in the long-term, general case, it's a pretty significant losing bet.
However, you can "beat the house" at this game by having a better understanding of when things are more likely to happen than the insurance company's "general-case" calculation. If your hot water heater is over 30 years old, and you don't have to tell them that so they can figure it into their price, then odds are you will need to replace it (on their dollar) before they can break even on your policy premiums. If the policy covers replacement prior to total failure, it's a pretty sure thing for you. Same with roof repair; almost nobody pays for a new roof themselves, they just wait for the next hailstorm after the 20- or 30-year rated life of the roof has passed, and pay the insurance deductible for the (overall much more expensive) reshingling and/or resheathing job.