I have some experience on being recruited. Most of the messages you receive are indeed junk.
But that's not the value of LinkedIn. The value is being connected and receiving recommendations from your current or former colleagues. That's not something you can easily maintain on your own.
And if you want to be recruited, then you have to actively improve your profile and even to actively seek a job — this means maintaining relationships with capable recruiters that can filter out the junk for you, or even contacting the companies that you like directly. And in both cases having an up to date online profile helps.
In other words a combination of outbound and inbound marketing. LinkedIn can help with both, or it might not help, but passively receiving messages from recruiters is not the provided value.
Due to the supply and demand curve, software developers have gotten lazy, but marketing is a soft skill we should all learn.