I agree it's not 100% perfect, and things do slip through the cracks; including in cases of big tech companies that move too fast compared to legislation and so can get away with what is essentially large-scale fraud, tax evasion, privacy violations, etc.
But the idea is if the market itself cannot solve the problem and it's causing significant harm to society then legislation is supposed to step in to prevent the behaviour deemed harmful.
https://keydifferences.com/difference-between-law-and-ethics...
This means you can act unethically and legally at the same time.