It’s illegal everywhere but certain parts of Nevada. When you walk around the streets of Las Vegas you’ll therefore see hundreds and hundreds of fliers for girls.
As for the history… it’s a sordid one. Read e.g https://en.m.wikipedia.org/wiki/Chamberlain–Kahn_Act. The US imprisoned women with venereal diseases found near military bases. Things sort of went from there, and also involves the “morality” of the American Christian and fears of the Progressives. Some more good reading: https://repository.library.georgetown.edu/handle/10822/10512...
Today it is a partisan issue and one worked on at a state level. Manhattan’s DA vowed to “no longer prosecute prostitution and unlicensed massage” as of this April.[0] …meanwhile the Texas governor in August made buying sex a felony in August, the first state to ever do so.[1]
I don’t expect any significant national progress on this in my lifetime. But there has been a sea change in blue states over the past generation.
[0] https://www.nytimes.com/2021/04/21/nyregion/manhattan-to-sto... [1] https://thehill.com/changing-america/respect/equality/567760...