The dual code international initially ruled himself out of the Kiwis' title defence starting later this month, but changed his mind within hours of coach Stephen Kearney releasing his squad for the tournament in Britain, Ireland and France on Tuesday.
Williams' u-turn has proved controversial, with one New Zealand selector saying he had "disrespected" the team, but Kearney made it clear the bulky 28-year-old was too valuable to leave behind.
"It's been a tough situation, but Sonny brings things to the group that we couldn't ignore," Kearney said on New Zealand Rugby League's website.
"He missed our 2008 World Cup win and his inclusion will be a great asset in trying to repeat that success this year.
"It's not only his footballing ability, but also what he brings off the field which will benefit the team."
Williams, who helped the Sydney Roosters win Australia's National Rugby League title on Sunday, replaces Melbourne Storm's 21-year-old Tohu Harris in the 24-man squad.
Harris was to have accompanied the squad in a development role, but NRL side Storm had decided it was in his "best interests" to stay in Melbourne and have a decent off-season, NZRL said.
"Tohu handled the situation as well as anyone could," said Kearney. "It was a conversation no coach would like to have, but he's a terrific young man and I'm sure he'll have many more opportunities to pull on the black jersey."
Williams earlier said that he had "jumped at the chance to chill out and rest."
"After having some time to really think about how much representing my country means to me, I decided to then put my name forward for selection," he said in a statement posted on his Twitter account.
Williams' back-flip was not welcomed by all of New Zealand's rugby league community, and team selector Richie Barnett made his displeasure clear.
"In some way he has probably disrespected (New Zealand's squad) but he's made a decision and we've just got to cop it on the head," Barnett told News Ltd media.
"At the end of the day, we're here to win a World Cup, we're not here to please people on moralistic grounds."
Williams, who won a World Cup with the All Blacks in 2011, has been tight-lipped about his future plans, but is widely tipped to quit the NRL to revive his rugby union career in New Zealand with Super Rugby's title-holding Chiefs.