For old people it is better to invest with their money
By the time one is old, their cognition has reduced and they are no longer having the risk taking mindset of the younger age. In other words, they would be too late. No offense intended to any aged person reading this though. You can start investing anytime, but keeping it all for the old age is not the correct decision.
but for young people I think it will be good if they invest for their brain by keep learning. I agree with your main point that saving is important. For young people it is better for them to use their money to buy books or pay tuition or course.
You are assuming that the person already has money with them. Keeping aside the fact that in third world countries parents pay for their child's education, I dont think that statement is applicable everywhere. Still getting a proper education is also an investment, investment in one's education and future. So that has a long term value. Of course when they start earning they can start saving and investing like the OP says.
If they don't have money they still can go to the library. That's my opinion.
A library is a last resort, you cannot depend on a third part system for your own education. What if someone lives in a locality that does not have a library nearby or if that library is closed down due to an ongoing pandemic?
A library can help and it seems very nice to hear those news about some poor kid studying from library and reaching somewhere big, but dont get too rosy, because this is a classic example of a surviorship bias.