I've always worked in a social good type of company. I love knowing my work directly contributes to improving society, and in fact I've made it my slogan in my resume. Currently I work for a startup that helps people find help from non profit orgs. I wouldn't say I gave up anything to work in this space, except that it's not a bleeding edge space with the latest in tech. Instead we have to work with non-technical people that run non profits, government agencies, insurance companies, etc.
To give you an idea, I met with a "head of IT" that sent over private info over unsecured email and they didn't know what SFTP is or any best practice of encryption... So our devs wrote a mini portal for him to authenticate and upload his info, because FFS.
I'm not currently working on it, but for years I worked for a telehealth startup/research project, building and maintaining their systems. The quantitative and qualitative analysis (including RCTs) done by the research arm all indicated that it has meaningful positive effects on the users.
I did have to make sacrifices financially (I doubled my salary within a month of leaving) but I went in knowing what I was doing so I don't regret that. That's a pretty substantial downside, so it's completely understandable that more people don't go that route. It's unfortunately a bit of a self-reinforcing problem because working with highly competent, friendly coworkers like you get at big tech is an experience that is hard to find at places without big tech budgets.
There's no such thing as social good. There is only individual good, and what is good for one individual might prove inimical to the interests of others.
I'm not a software engineer; I both freelance and use my tech skills as extra incentive to hire me into non-tech positions. (I'm a generalist to my core). So my answer is going to look a bit different than people who've gone into Tech.
However, I feel/felt pretty good, ethically, about all the tech work I've done, which can separated into a few buckets:
* Work for education systems and libraries. Yes, there's a bunch of stupidity and politics, but at the end of the day, I was making things that helped people learn, and that felt pretty good.
* Work for local or small businesses that otherwise wouldn't have their problems solved at all. In these cases, the businesses were either small enough that I knew the owners + how they ran things and could be assured they weren't exploitative dicks or what they did was important enough (e.g. hospice care) that solving problems and saving them time makes my local community better. (If I help the local lingerie place with IT things, they can serve more people and fewer women are uncomfortable, my local hospice running better means more care for my and my friends' parents, etc.)
* Work for non-profits or other organizations whose missions I believe in. I dabbled in nonpartisan political/civics communications work, for example, and I felt just fine using my tech skills to help people understand things like how elections are administered.
The key thing I've found to finding work that doesn't make me hate myself is the funding model of the organization.