I've worked on things which have had a positive contribution to society. It can be something as "simple" as making a confusing form simpler, or it can be something as complex as advising on national technology policy.
The salary may not be as high as a private company (although you'd be surprised) - but the pension is usually pretty good. You get to work on things which - nominally - a plurality of your fellow citizens have decided is a priority.
If your national government isn't your thing, then your local government is probably crying out for decent technologists. That way you can make an impact on your community.
Are you going to agree with everything your bosses say or do? No. But that's not much different to any other organisation.