Because otherwise they can not serve alcohol. This is the law because alcohol is an addictive substance and more addictive if interacted with in younger years as your brain is not fully developed. And "we" as a society deem alcohol consumption problematic as it is associated with risks for other societal participants, like drunk driving accidents and domestic violence. Similarly why you can't enter a casino underage.
The underage crowd can't enter a space that is specifically exists for experiencing the prohibited behavior. Where the internet is a more general space and we are restricting anyone that has not proven to be adult. And what are we restricting them from? Posting/publishing & accessing content, that sounds like age based censorship.
Would someone underage have less rights to receive or publish unpleasant/controversial topics under the First Amendment? I think you need to have a very strong case to undermine those rights and I just don't think "might protect the kids" (which is debatable) is strong enough.