Do you have an example of a court saying that violating robots.txt violates an existing law?
In Ziff Davis v. OpenAI [1], the District Court for the Southern District of New York found that violating robots.txt does not violate DMCA section 1201(a) (formally 17 U.S. Code § 1201(a), which prohibits circumvention of technological protection measures of copyrighted content [2]).
It's my understanding that robots.txt started as a socially-enforced rule and that it remains legally voluntary.