The government's role, economically, is to do things that private industry wont do that need to be done. The space program was an example of this. Research into medical advances that will save the lives of poor people would be a good example. Work on transportation backbones, as this is generally too large a project for private companies. Currently we are facing peak oil and without significant investments in an alternate transportation system the US is going to be in very big trouble soon. Building a new system (which would probably rely mostly on rail) is not something that is within the capability of any one company, or in their best interests, but it is still a vital project that needs to be completed.
Who are you to say what is and what isn't worth doing? To challenge your specific examples:
- The space program generated an awful lot of R&D, but it cost even more money (so high cost to development ratio). Privately funded research would have been more efficient
- Health care needs to be cheap, government bureaucracy makes it really expensive (all that testing) and patent law prevent the goverment from reducing the cost
- Relying infrastructure spending has decent chance of being successful (and thus profitable), gets funded by massive pension funds (who like promise of good returns in a decade). Doing something unprofitable is by definition a waste of time.
- If peak oil starts to become a problem prices will go up (supply and demand). This means that it will become cheap to use alternative stuff and hey presto, problem solved.
Building railway lines and stuff privately is by no means
unprecedented.