This is a good point. The government started investing in spaceflight because it was seen as important to defense. In the early 1960's, the best plan for spy satellites were manned space stations (see the planned Manned Orbital Laboratory). But as time progressed, we saw that we were much better off using automated systems for space. Yet we had already started manned missions, so those just kept shambling on, even long after the reason for them no longer existed.