The hope is that the punishment proscribed by the law is enough to make people think again before breaking it, and, if the law involves depravation of liberty (jail), that people who do break it are removed from society for a limited amount of time to prevent them further transgressing.
This is civics 101, honestly, anyone that's a student of history understands that laws are created because all other forms of preventing what society agrees to be bad behaviour have failed.
Laws, therefore, are the last resort, because everything else has failed.
Edit: I just want to add (here, because it's too late to edit my original comment) that someone /flagged/ my comment that disagreed about there being a thing where speech/information flows completely uninhibited - hilariously proving my point :-)
Shame and ostracisation handled this through antiquity. There is no evidence introducing those elements online cannot work.
> would at best create an echo chamber of government supported online stupidity and misinformation
But that’s what we got anyway.
It’s just as clearly the case that a lack of regulation amplifies people willing to be stupid online. Taking that amplification away takes us back, per your worst case, to what we have now.