Occupational licensing is bad, but doesn’t explain the financial rewards of seemingly useless education.  Except, Vipul Naik points out, for foreign workers.  Here‘s Vipul, reprinted with his permission:

I think Bryan
is broadly correct that government regulations in United States
employment law do not explain the importance that employers give to
educational credentials in the labor market. However, for foreign-born
seeking employment in the US labor market, it seems like educational
credentials are given strong preferential treatment in official US
immigration law.

To take the example of the H-1B law:

People with masters degrees from US universities are eligible for 20,000
cap-exempt slots per year for the H-1B quota (for Form I-129). So
having a masters degree from a US university significantly increases
your chances of getting the visa, since you are less likely to need to
play the lottery.

(2) People with masters degrees (not
necessarily from US universities) are exempt from additional
attestations (about displacement of US workers) on the H-1B LCA that
apply to H-1B-dependent employers and willful violators.

Having a bachelor’s degree is not a strict requirement for getting a
H-1B; work equivalency can be used in lieu of educational degrees. But
the work equivalency criterion is skewed against work: you need 2 or 3
years of work experience to make up for 1 year of education.

Nonprofit research institutions are exempt from the annual H-1B caps and
also from some parts of the H-1B fees. Therefore, universities and
research centers find it much easier to hire postdocs, assistant
professors etc. on H-1B than private firms.

Other examples of
laws favoring educational credentials: EB-1 and O-1 visas are easier to
get based on academic accomplishment (papers, etc.) than based on
comparable accomplishment in the non-academic world (this is a
subjective assessment). Also, options like Academic Training (for J
status holders) and Optional Practical Training/Curricular Practical
Training (for F and M status holders) are only available to people after
they have spent some time studying in a US educational institutions.

While employers probably are naturally more inclined to hire people who
are studying in US universities, and therefore people have an incentive
to go to US universities in order to place with companies, I think
these laws further bolster credentialism. In particular, I think the
effect of these laws is clearest on Masters degrees, where applicants
often pay a significant share of their tuition (Ph.D. applicants
generally choose the US more because of the quality of the research at
universities, though the potential for a better labor market is probably
a contributing factor).