As somebody who believes that this court is more motivated by partisan political concerns than legal reasoning, it seems likely to me that Roberts ruled against this not out of true legal principle, but because it would be so wildly unpopular in an election year that he doesn't like the consequences.
There are many realities that seem plausible here.
https://www.govinfo.gov/content/pkg/USCOURTS-txsd-1_18-cv-00...
States challenged DACA as a violation of the APA and the Take Care clause of the Constitution. The judge argued that it probably was illegal, but denied their request for a preliminary injunction because of all the negative consequences. I haven't been able to find a final ruling on this case, not sure if it has been decided or is still pending.
EDIT: yep, still pending. It was apparently waiting for this Supreme Court ruling before moving forward:
https://www.courtlistener.com/reca/gov.uscourts.txsd.150168/...
So the cart's a bit ahead of the cart I suppose - the Trump administration's rescission was unlawful, but the legaity of the original creation is still not decided.