I think lots of people contribute everywhere without getting any benefit at all.
I don't doubt that some who do contribute hoping for, or expecting, some ancillary benefit.
I'd suggest that pretty much the only tangible benefit I can see is those searching for a job. Contributing in public spaces is a good technique for self-promotion as being skilled in an area.
Then again I'd suggest that the majority of people participating on those sites are already employed, so they're not doing it for that benefit. I'd even argue that their day job accomplishments are likely to be more impressive than their github account when it comes to their next interview.
So perhaps I can reassure you. I'm pretty sure people will continue to absorb information, and skills, and will continue to share that with others. This has been the way for thousands of years. It has survived the inventions of writing, printing, radio, television and the internet. It will survive LLMs.