Maybe Justice Roberts ended up voting to uphold 'Obamacare' to prevent Clarence Thomas from casting the deciding vote in the case. Calls to impeach Justice Thomas for not recusing himself based on his wife's financial interest in the outcome were renewed even though Thomas ended up in the minority. If the law had been struck down 5-4, Thomas could be said to have cast the deciding vote, and those calls for impeachment would have been much louder. Thomas would likely have brazened it out, and gotten away with that course, but the reputation of the Supreme Court would have taken another severe blow, perhaps comparable to the reactions to Bush v Gore and Citizens United.
Similar things have happened before. When he was Chief Justice, William Rhenquist occasionally switched his vote to turn a 5-4 majority into 6-3. I believe he said it was because he didn't want an important case to be decided 5-4. It also gave him the option of writing the majority decision, which he may have wanted so he could limit the scope of whatever precedent was set.
On December 31, 1974, Justice William O. Douglas had a stroke that left him with a paralyzed left leg and possibly with a cognitive deficit. The other justices decided they wouldn't let Douglas cast a deciding vote, by postponing a final decision on any case in which the other eight were split 4-4. By the next year, Douglas had retired.
So perhaps Justice Roberts voted in a surprising way on the Affordable Care Act case for the good of the Supreme Court as an institution.