People are going to do what they want to do. When you ban something that's the end of your regulation on it. So it goes underground and becomes less safe for everybody that's involved with it.
When you legalize it you can be more nuanced with the regulation, ultimately making it safer and having better outcomes for a huge majority of the people involved. You won't get 100% but it's certainly better than the 0% you're getting with a ban.
Of course the more you over-regulate and create effective bans the lower that % of people following your regulations is going to be and you're back to square one. Take a look at the history of abortions through being banned, coming into legality, and then back into over-regulation/effective ban in some places. Rate of abortions doesn't go down meaningfully when they're explicitly or implicitly illegal but rate of complications from abortions goes way up.
An anecdote for you: someone I know was instrumental in getting the "condoms in porn" law architected in LA county. The goal was to normalize condom use in the face of multiple STD epidemics including HIV. On the surface this is great. But porn with condoms is insanely less popular than porn without condoms - effectively making this new law a ban on producing porn in LA county. So what happened? Productions either went half an hour down the road to the next county or they just stopped actually filing permits and went unregulated meaning no more enforcement of the regimen of testing etc that porn actors were previously required to adhere to, leading to less safe outcomes for the folks involved and no meaningful increase in the amount of porn featuring condom use.
Sex work should be legal. I do not want to use the word “prostitution” as it carries unnecessary stigma. The main consideration is the safety of sex workers. Exploitation does exist but victims are hesitant to go law enforcement precisely because sex work is illegal. On the flip side people organizing sex work enterprises (aka “pimps” and “madams”) are already breaking the law so for them application of violence is not out of the framework.
I think this is a tough one, and I'm not sure where I stand on this.
On the one hand I don't think the government should be able to tell you what you can and can't do with your body. If you want to sell your body, you should be able to.
But on the other hand, if you legalise it then you open the door to people being exploited, and I'm aware that people are exploited now in prostitution, obviously, but I feel if it's legal it might be harder to punish those that do.
So maybe on balance it's better for it to be illegal if it protects at least some people.