Considering putting cash under your mattress is a better investment than paying for law school, yes, you are technically correct.
However, I don't know how "worth it" financially even a master's degree in Computer Science is. At best, I feel like it's break even in most cases: the year or two you spend getting the degree might be better spent on the job, especially if you have a decent mentor.
In one case, a guy I mentored directly out of undergraduate ended up going back and getting his master's. I think he'd say that it made him feel more confident with certain concepts, but then, I picked up the equivalent information in the course of my 10-year career with only an undergraduate degree. Any reasonably curious programmer would. It certainly did not make a difference in his income.
As for PhDs, I have never hired one. They seem to universally have an inability to think concretely or in a step-by-step manner. They have the skill set of a junior developer but expect the salary of a senior developer (at least). Ultimately, I can only imagine hiring one if they had significant experience in a very specific area that is difficult to hire for.