West Ham gets to try Carroll out for a season and see if he's worth the option price.
Liverpool gets out from under his salary for a year and presumably gets an option price that's better than anybody was willing to pay outright now.
Carroll would do it to try to get a better situation than he has right now.