This is not quite true. They're optimizing for throughput, not max dollar value. If they optimized for the maximum amount of money they could get you that would come at the cost of their time which would lower their throughput of placing candidates and hence the maximum amount of money that they can personally earn in aggregate.
They'll still try to spin you that line though.
WA state law makes it very clear as a candidate I don’t need to share salary information, and by some readings of the statute it’s illegal for them to even ask.
My most recent job is at a very large public company where the salaries are well published (levels.fyi) - there was no need for me to give a detailed salary history of all my recent jobs.
If the value-add of a recruiter is getting a better negotiated salary, what is the value-minus of putting another point of failure between me and a job I want. Surely it’s possible that over time the minuses are greater than the pluses.
It is a bit petty that they told the company that you were a poor candidate, but you seem to not understand what was happening. And it could have been they had already mentioned your name to them, and then had to explain why they suddenly were not representing you. I don't know, but that is a reasonable explanation.
I personally have had a mixed bag with recruiters: many I have dealt with are worthless in that they don't understand the jobs they are recruiting for (so give very bad matches to both sides), but I have been lucky twice and had recruiters give me great jobs and handle the pay negotiations so well that I probably got $20-40K/year more than I would have by myself (if I had somehow found those positions).