The law is mostly complied with because there is a social consensus that it's mostly fair and that not obeying it is wrong.
It's already illegal for minors to watch porn. It doesn't stop them doing it though, does it? What will stop them is proper enforcement!
Drugs are illegal, but that doesn't stop people. Likewise teenagers who smoke, drink and have underage sex.
The reality is that people will break laws if they think they can get away with it, whether it's parking on double yellow lines, speeding, shoplifting, common assault, etc.
The "moral compass" is very different for different people. Yes, some people will comply with every law, but I'd say the majority will have their own idea as to which laws to comply with and which to ignore.
That's why proper enforcement is an absolute necessity. If a law isn't going to be enforced then it needs to be scrapped.