Why would it be contrary to free speech? That doesn't make any sense. — Now, saying it would violate involuntary servitude
does make sense.
Free speech in the sense that he can’t be forced to say what he doesn’t wish to say.
Because the case isn't about a standard, pre-made cake which of course the baker would be obligated to sell to anyone who came in to buy it.
Instead, the Court noted that in this case the baker designs a custom cake based on their own creativity and design ideas. That is a form of expression, just like making a sculpture or writing an article. The 1st Amendment protects the right of everyone to not engage in speech that they do not want to engage in, just as it allows people to say what they want, or create the art that they want to create.
It is a thoughtful ruling based on the particular facts of the case, and it is consistent with 1st Amendment law.