I'm a software engineer at a very large adtech vendor.

The basic argument for display ads not being evil is that they give journalists and other content creators a way to get paid for their work. A lot of people, concerned about incentive distortion and other problems with ads, would rather see this happen through alternative models like subscriptions or microtransactions, but it's not clear to me that that can work. In particular, the amount that publishers would have to charge in order for such models to be revenue-competitive with ads far exceeds the average reader's willingness to pay—which suggests that ads provide a significant consumer surplus.

The question that currently worries me a bit is where that surplus comes from. One possibility is that the cost to consumers of being shown ads is much greater than it appears, because ads strongly influence consumers' behavior in ways that directly oppose their own interests. (Note that this is different from the hypothesis that publishers manipulate readers' behavior to maximize ad revenue; this is about the what advertisers do directly.) Obviously there's some of this going on; the question is whether it's enough to negate the consumer surplus. (Some also argue that there should be zero tolerance for this, even if the consumer comes out ahead, because it undermines their ability to navigate the tradeoffs in their own interest; I won't get into that argument here.) I think this hypothesis can't yet be ruled out, and if true certainly means that I'm making the world worse, but I'd like to see stronger evidence for it before I believe it with much confidence. In particular, lots of people who argue strongly for it seem to be basically motivated by their own aesthetic revulsion towards ads, and rarely present much real evidence.

Another hypothesis is that advertisers are basically engaging in a dollar auction against one another, paying more than they should for ad inventory because if they don't their competitors will, and/or because they can't measure the effectiveness of their ad spend well enough. (Obviously we try to give advertisers the tools to measure and understand the effects of what they're doing, but some argue that it still doesn't work well enough for that purpose.) The proceeds from this dollar auction effectively wind up subsidizing publishers, readers, and me. If this is true, then I think I'm making society better, by moving wealth from things like consumer product marketing (less socially valuable) to things like journalism and content creation (more socially valuable). Such an arrangement may not be stable in the long term, as greater competition increases selection pressures against companies that waste money like this, but I'm okay with crossing that bridge when I get there.

There are likely other possible explanations that I haven't thought of.

Two other relevant factors in defense of what I do:
1. My job in particular is significantly about defending users' interests. As HN readers are well aware, there are a lot of ways that display ads these days just plain suck for users, and much of what I work on is about finding ways to make that less true.
2. I donate a significant fraction of my salary to the most socially valuable causes that I can find, and I intend to increase that amount a lot more once I've got a financial safety cushion built up for myself.

I don't think I could do much more social good than this while still working on pure technology. I do think I could do a lot more social good if I took a job that involved significantly less programming and more of other kinds of less-pleasant work that I'm worse at. I frequently feel bad about not doing that, but it does seem reasonably likely that I'd burn out if I did.