Yes, artistic freedom in comedy depends on the ability to say or do anything, even if it runs counter to social norms. That’s true of any art form. Comedy isn’t special in that regard. And yes, of course, comedians should have the legal right to say whatever they want (within the obvious limits of libel laws and copyright laws and such).
Does this mean that comedians should get a free pass when the things they say and do are screwed-up? Does it mean that comedians — or any artists — should be exempt from criticism when the things they say and do dehumanize, trivialize, shame, reinforce harmful stereotypes, support and rationalize the unequal status quo, and otherwise injure entire groups of people? Especially groups of people who have already been hurt a whole hell of a lot, in this exact same way, for centuries?