But you're oversimplifying the case here. They weren't complaining that the law was being published, they were complaining that their standards were published. The court agreed with PR that once those standards were incorporated into law, they were subject to fair use publication under the auspices of making available and explaining our laws to the public.
The courts agreed and here we are. But as another user wrote, this wasn't about copyrighting the law, it was about the inclusion of copyrighted material in the law and whether or not it fell under a different category with regards to fair use.
I'm sure I'm oversimplifying or missing something too, but I, who am generally opposed to how copyright is currently handled in the US, can see that there is more nuance to this case than your post admits to.