I work for a company with a mandate to develop software products for progressive charities. We created some libraries that we wanted to open source and, like the OP, we weren’t satisfied with the licenses that we could find.
We created the Just World License so that, at the very least, our code wouldn’t be used by those that are working against the goals of the charities we support. (Here’s an article explaining our reasons behind it)
Below I’ll address some of the objections to ethical licenses raised in comments and answers. In doing so I’m going to draw comparison to the GPL because it is also an example of a license that's drawn from a strong ideological viewpoint and so is instructive in how a license is more than just a legal document, and the aspects of it we’ve come to accept.
Why (not) ethical?
Many of the objections I've read are related to the enforceability of such a license, but I would argue that the purpose of an ethical license is not to enforce it in a court. In fact, most legal documents you really don't want to be testing in court - it's expensive and painful. Yes, you should make them clear and unambiguous, but most people don't draft legal documents with the primary goal being to take the other party to court.
As people have (rightly) pointed out, if a big company wants to use your software despite restrictions, they likely have the resources to bury you in legal paperwork.
But, this is no different from the GPL, and the GPL, too, wasn’t written so that FOSS developers could haul big companies to court for misusing open source code. Yes, it’s legally specific and possible to enforce, but that wasn’t the primary purpose the authors had in mind for it. They created the GPL to spread an idea - the idea that software and it’s source should be freely shared.
Likewise, in creating an ethical license, we want to spread an idea - that our software should be used for the betterment of the world, and that we as developers can take responsibility for how our software is used.
That being said, I would also argue that an ethical license can be enforced. Even with the extremely vague licensing terms of JSLint, IBM was sufficiently concerned about enforcement as to ask the author for express permission to use JSLint for evil.
Yes, big tobacco could use our code and keep quiet about it, but the fear of being discovered or whistle-blown and the possibility of enforcement is enough for most companies, even the ones doing bad things, to decide it’s not worth the risk and go and find some other code.
Restricting usage for illegal things is pointless
In writing an ethical license we decided not to exclude illegal acts for this reason, and also because some countries have really bad laws that restrict people’s freedoms in awful ways. If the activists working against those things want to use our software, they’ve got enough to worry about without worrying that we might show up and add a cease and desist to their troubles.
If it’s bad, there are laws to stop it
<insert obligatory video of lawmakers asking Mark Zuckerberg about sending an email over WhatsApp>
Our lawmakers are, unfortunately, among the slowest to move when it comes to responding to changing social norms, let alone technology. For starters, it’s 2018 and there are still products on shelves that are made by actual slaves.
Ethical cannot be defined
The world is not as grey as it’s often made out to be.
Our license would prevent people from using our software for (among other things) taking action that is known to ruin the state of the planet for future generations, exploiting slave labour, promoting racism, or hacking behavioural psychology to make people waste loads of their life clicking ads.
These aren’t exactly the trolley problem.
Ethics is subjective
Yes, but this isn't a bad thing.
Some of our most essential decisions are subjective. If you're interested, there's some really interesting stories of people who've had their emotional centres damaged in an accident and are no longer able to function even though their reason and objectivity is completely intact.
Less philosophically. The notion that it’s wrong to take FOSS software and improve it without releasing the changes is also a subjective position. This is a subjective viewpoint that forms a key part of the GPL and not everyone in the software development world can agree that it's a good thing, but this difference of opinion hasn't brought down the FOSS community yet ;-)
It would be inconvenient
Well, that’s kind of the point. If a company is writing software for ethically dubious acts, then an ethical license is meant to be an inconvenience.
The same could be said of some FOSS licenses. Some companies today are using tools like license checker because they don’t want GPL code in their products.
If every author threw in their own definition of ethics and we had loads of non-standard ethical licenses then this does become very arduous and inconvenient, but if, like we do now for general open source, we could agree on a handful of standard licenses there’s no reason it would be any less convenient.
Bad Companies will just write their own
Good. Let them waste their resources if they want to profit from harming people and our future.
I’m not going to kid myself that placing the small libraries I've released off limits is going to materially inhibit big evil corporations, but what if bigger projects did?
For example, Apache’s Hadoop is being used by oil and gas companies to help them operate more profitably at a time when they should be shutting their doors so we can avert a climate disaster.
If the Apache Foundation determined that such uses did not fall within the public benefit that their mission envisions for their resources and decided to codify that in their license, the companies would have to turn to something else, maybe an expensive proprietary solution. This drag on the bottom line of a company that harms our future would be a good thing.
It's a new idea
All this said, the Just World License is a new idea. We think it's got legs, and we’d welcome feedback or pull requests to make it better.