But it does benefit you, personally: by not having your information out there in public, you can claim whatever you want when you go into salary negotiations, and the hiring company has no way of knowing that you'd be perfectly happy with a significantly lower salary. Generally, whichever side has less information public about them is at an advantage in negotiations.
Unfortunately, this leads to a prisoner's dilemma situation where each individual worker would be better off if everyone shared their salaries, but each individual worker is slightly better off if they don't share their salaries.
FWIW, my first programming job only paid me $32k a year. But I was straight out of high school (no college), and I thought it was a princely sum because I was getting paid more than my Ivy-League grad high school teachers were getting.