Not all jobs or service contribute to society. But if you invest in a company that provides goods and services that people don't want, that money is lost and you lose your ability to invest further.
When government provides a service that people don't want, that service can continue indefinitely, especially if the few who benefit can contribute back to the politicians who keep it going. Lockheed Martin and Boeing can contribute to some politicians to make sure that wars continue and they reap back way more than they contributed from the taxpayer who's only option is to vote between two pro-war candidates. Those jobs making bombs for Saudi Arabia to drop on Yemen don't contribute to society, they are a determent to society, yet they continue without end because nobody loses on that investment as long as the taxpayer can be forced to pay for it.
When government provides a service that people don't want, that service can continue indefinitely, especially if the few who benefit can contribute back to the politicians who keep it going. Lockheed Martin and Boeing can contribute to some politicians to make sure that wars continue and they reap back way more than they contributed from the taxpayer who's only option is to vote between two pro-war candidates. Those jobs making bombs for Saudi Arabia to drop on Yemen don't contribute to society, they are a determent to society, yet they continue without end because nobody loses on that investment as long as the taxpayer can be forced to pay for it.