Two aspects are important to consider here. First is that the law is necessarily arbitrary; in this sense knowledge or ignorance of the law is irrelevant - the knowledge of the Judicial apparatus and its personnel is what is actually important.
The second aspect is necessarily a corollary of the first. Namely, that anyone with sufficient knowledge can structure their behavior to make otherwise unlawful behavior entirely legal. In fact, the entire economy and political apparatus is dependent on this mechanism to function, because without it there would be no effective heuristic for identifying opposition to the state (the actual purpose of all judiciary and enforcement apparatuses).
For example, it is highly unlawful in 99.99% of the country to pay a stripper to fuck you. It's 100% legal everywhere in the country to fuck a stripper, and then make it rain on them when they go onstage at some time before or after. While this looks a hell of a lot like money laundering, good luck proving that without written or recorded conversations attesting to that. The only thing that is truly unlawful is good record-keeping and poor operational security. The state wants only smart "criminals" operating; like knows like.
If it weren't for this fact, pretty much every marginal business (read: 80% of business) would go bankrupt. Unprovable accounting control fraud, while resulting in the occasional Enron, is also the only reason that taqueria down the street has a profit margin after sales and other taxes. Taxation is the primary motivating force behind fraud and various other distortions in the economy.
Rampant control fraud is also why tons of people who are otherwise useless have jobs rather than are yet another SNAP/SSI recipient. Corporate Managers looking for more direct reports to fuel their promotions who are willing to fudge performance reviews to protect dead wood likely take off a good 10-20% of the unemployment rate all by themselves. This also allows them to protect the actually productive people when layoffs finally come due to economic conditions entirely out of the manager's control.
Of course this naturally comes with corrosive effects. If your business relies on control fraud to be viable this implies the optimal amount of shrinkage is nonzero; preferably some fraction of the taxation otherwise avoided. This is because any mechanism you can use to identify sources of shrinkage can also be used as a means of assessing your "true" tax burden. As such, those mechanisms are routinely omitted as "cost saving measures".
This is what is behind most complaints of being unable to staff businesses. Untrustworthy people cannot be allowed anywhere near decision making. Even if they don't steal directly they'll do other stupid shit that's liable to get them to turn stoolie in desperation.
Nevertheless, if you have to scale a business you just have to swallow that bitter pill and adapt. If you've ever wondered why "mushroom management" (keep them in the dark, and feed them shit) is so common, it's because it's an adaptation to these realities. Managers call these sort of interactions with employees "baby talk", as it's most commonly employed on young and idealistic employees. Anyone who can't see thru it is clearly not suited for anything beyond toiling. Similarly, anyone who "looks like a criminal" (read: non-beta) can't be trusted.
Which brings me to the "heuristic for identifying opposition to the state". Much like corporate, governance has had to scale far beyond its actual ability to employ coercion and maintain some semblance of their preferred order without a hell of a good filter. Viewed through this lens, the reason why some things are "unlawful" and others not becomes immediately clear.
For example, why has every single attempt to roll out a "cashless society" (read: no bearer instruments of any kind) failed so spectacularly? Because if there is no clearly identifiable activity such as "withdraws and deposits large sums of cash routinely" to narrow down your list of potential malefactors, there is no option besides a full index scan to increase revenue or suppress organized "subversive/criminal" activity. This is why bearer instruments such as cash (read: non-refundable) remain allowed in the physical world but ruthlessly suppressed in the digital realm.
The commonly used excuse by the payment processors for their official oppression of things like sex work is the prevalence of chargebacks. This makes sense to a degree, as drunk idiots who don't realize their wife reads the bank statement will always exist. Nevertheless, there is no technical reason even under traditional digital finance systems that nonrefundable transactions can't be supported. The fact that they don't is because the government explicitly prohibits such as it allows anyone to unprovably be an Unlicensed Money Transmitter.
To be fair, it's not exactly smart to engage in a transaction where one fat finger can increase the order of magnitude of a mistake. This is why I'm still astonished that digital transactions (such as with a credit card) aren't by and large subject to escrow. It's also worth noting that one of the important functions lawyers tend to serve is that of escrow. Much like with your taxes, having legally protected client confidentiality allows a great deal of otherwise questionable activity to be beyond proving it isn't entirely above board. This is tolerated because lawyers are almost never threats, but the biggest boosters of the state that exist.
If there's any moral to this story, it's that two wrongs don't make a right. The deadweight loss to the economy due to the impossibility of valuing things correctly thanks to rampant and tolerated control fraud is quite large. All equity you acquire is necessarily a pig in a poke. As such, there's no "free lunch" -- investing in businesses you aren't personally involved in to a degree you can see through the bullshit is simply gambling. That's the real meaning of "ignorance of the law is no excuse".