Frameshift challenge: You ask how the SCP Foundation can be seen as the good guys given all the stuff they do, but the SCP Foundation are intentionally not supposed to be seen as good guys. They are intentionally written to be seen as "the lesser evil" according to most of the authors. SCP Foundation is fundamentally a horror series, and part of that horror isn't just whatever creepypasta-inspired object the Foundation has contained. It's that the framing device that this universe is set around revolves around a bunch of dubiously ethical scientists whose motivations at best are "the greater good" and at worst "for science". Many researchers (Dr. Clef, Dr. Kondraki, Dr. Bright) are sociopaths or worse. The Foundation-verse regularly falls into "Humans Are the Real Monsters", which is a common horror trope.
I can think of several good examples of "the Foundation are not the good guys". Note that these are all not examples where the Foundation has to do horrible things for the greater good or to prevent the end of the world from happening like SCP-231 and Procedure 110-Montauk or kidnapping babies on an industrial scale for containment procedures that involve the sacrifice of innocents, but are based on in-universe selfish, misguided, or needlessly cruel reasoning:
- The SCP's goal is to keep all anomalies contained so they can poke at them. They're the "lesser evil" compared to groups like the GOC who just want to kill everything, but this still involves kidnapping people like Iris and locking them up for the rest of their natural lives so they can poke and prod them. Or the SCP Foundation employee from the future they contained (instead of, say, putting him on the payroll), just because he appeared through anomalous circumstances (and are implied to have treated him like he was a D-class rather than a fellow researcher because he was black).
- The Foundation also contains beneficial anomalies in addition to unknown or hostile ones. They claim they will release the technological applications of these anomalies to the public once they can fully verify how they work, but if you look at the actual list of explained SCPs you'll note that none of them have any positive impact on human well-being in general. There's no medicine or scientific breakthrough that was originally discovered by the Foundation studying anomalies. The Foundation basically monopolizes all the best technology to itself and picks and chooses how humanity will develop based on their arbitrary criteria. The Foundation has functional faster-than-light technology that doesn't require anomalies to work, but keeps it hidden from the rest of humanity. The rest of humanity has no say in how society develops technologically or any choice in what they do, because the Illuminati-like Foundation is a parasite keeping their host contained and placid.
- The Foundation does all of this to safeguard "normality", but the thing is the Foundation are the ones that decide what is and isn't normal in the first place. An scientist making a breakthrough in a research lab like Einstein's theory of relativity could end up killed or suppressed because their research threatens "normality". In fact, the Foundation is specifically noted to be suppressing human technological development in order to keep them from advancing too fast for the Foundation's liking. This ties into the whole "the foundation has spaceships, advanced medicine, and FTL but keeps it from the rest of humanity". And if humanity breaks from the script the Foundation might just hit the reset button.
- At one point, there was a dubiously canon side story that revealed that there was no such thing as amnestics, and that the Foundation merely used advanced torture techniques to brainwash people into being too traumatized to remember the event and become pliant to Foundation mental suggestion. The guy who was the head of this was also noted to have obtained his wife via this way, by kidnapping a woman he had a fancy for and torturing her until he made her his Stepford wife. This got retconned later into amnestics being created by a giant eel god.
- The Foundation explicitly backs the totalitarian regime of North Korea, and is a major factor in propping up the Kim Jon-un government and is partially responsible for its "hermit kingdom" status, in the name of containing an anomaly which reduces people into obedient sheep for totalitarian leaders. Notably this was so bad that the Foundation ethics committee actually protested it, pointing out that the Foundation was essentially forcing thousands of people to live under a dictatorial regime, and got overruled.
- The Foundation also interferes in the lawful elections of various counties, including the United States. Multiple times.
- The SCP Foundation is horribly corrupt. Case in point the Foundation knows where the Fountain of Youth is but the 05s keep the location secret so they can use the fountain whenever they want. This is noted as a huge security breach (what if prolonged exposure created an infohazard or a psychoactive memetic?) and the 05s are clearly abusing their position to live forever (this is a theme with several SCPs), but no one can call them on it.
- Or the time the 05s reacted poorly to a researcher objecting to a test of a medical procedure to give them immortality on ethical grounds. Did they rationally and calmly take her words into consideration? No, they tortured her by exposing her to the untested medical procedure, which among other things involved being violated by parasitic flatworms akin to the Fate series.
- The SCP Foundation is depicted as being on "the wrong side of history" in many cases. One of the "explained" SCPs is drapetomania, the fact that prior to abolition movements African slaves were possessed with the "unnatural" urge to escape their masters and didn't see themselves as inferior. This wasn't "some evil gribbly from beyond space and time will be loose if African-Americans weren't enslaved, and this is for the greater good", the SCP of that time were just racist jerks (hence the SCP-EX classification). They also explicitly used African slaves instead of death-row inmates as D-Class personnel prior to abolition in the U.S. Even after abolition they still preferentially used black test subjects.
- The SCP Foundation is also behind the assassination of U.S. president John F. Kennedy John Lennon, Kurt Cobain, and Tupac Shakur, among other figures. The assassination of JFK had nothing to do with containing an anomaly, it simply had to do with maintaining a "consensus reality". John Lennon and other popular musicians turned out to be nothing more than human psychology, meaning the SCP Foundation had innocent people killed for no reason at all.
- The SCP Foundation has engaged in genocide of several innocent groups, including some who the Foundation merely listened to the bigoted superstition of their enemies rather than looking at the actual evidence. They are also keeping the Bigfeet marginalized and suppressed living in a subsistence lifestyle in the woods despite the sentient, human-like Bigfeet seemingly wanting to come to a peaceful compromise and return to a higher-tech lifestyle.
- Their plan in case aliens ever contact Earth and attempt to share technology is to turn human society into what amounts to the Imperium of Man out of the possibility that the aliens might not have good intentions.
- They have purposefully attempted to genocide the human race in at least one timeline. In another they turned into a totalitarian state and started running containment facilities like concentration camps.
- D-Class prisoners aren't always death-row inmates. In the event that the death-row population is not sufficient to meet the foundation's needs, the foundation will abduct random civilians off the street from to meet their needs. As you point out, given the low number of death-row inmates worldwide (only about 650 in all of 2019, and only 22 in the U.S., the only Western country with a sizeable death row population, with most of the rest coming from the Middle East and China), and the fact that the Foundation goes through what is estimated to be at least 12,000-15,000 D-class per year, and the high number of female D-class compared to IRL prisons (women almost never get death-row sentences, almost as many D-class were used to create Olympia as there are women death-row inmates in the U.S. alone) it's almost certain that most D-class personnel are either innocent political prisoners of totalitarian regimes, war refugees, or random civilians rounded up off the streets (kind of reminiscent of the controversy surrounding how the bodies in that Bodies: The Exhibition travelling exhibit may have come from Chinese political prisoners). The Foundation has also been known to engage in human trafficking. It's highly likely "oh, the D-Class are all criminals and bad people" is another lie the researchers are told to dehumanize their test subjects.
- Related to this, it's often claimed that the Foundation creates D-class through cloning or other anomalies. This is unlikely. The Foundation pretty much can't create D-Class out of nothing for fear of cross-contamination of anomalies, which the Foundation is strongly opposed to. Also, using an anomaly to create infinite D-Class was proposed with regards to SCP-1676 but was explicitly shot down by the 05s. Those are real people dying.
- The SCP Foundation also tests lethal anomalies on children.
- There are cases where they know for a fact a D class is innocent of the crime they were sentenced to (because the real cause was an anomaly) but they wipe the D-class' memory and keep them in circulation, they just don't care. Indeed, the Foundation frequently covers up its mistakes where innocent people accidentally get killed because of their screw ups.
- This isn't even getting into how sociopathic and abusive of their power the 05s and the researchers can be. Some of them are described as clinical sociopaths.
- Or all the one off-researchers who get in ethical trouble with the foundation, ranging from the people who use SCPs for their own pleasure to that guy who fed multiple innocent children to SCP-682 to that idiot researcher who tried to incorrectly banish a friendly child ghost without permission from the higher ups and the botched effort turned said ghost into a homicidal Satanic killing machine.
- The ethics committee, despite being the commissariat of the SCP Foundation, is hilariously ineffectual. I'm not talking about all the horrible stuff done for the greater good, I'm talking about how the 05s go behind the Ethics committee's back to commit xenocide, the self-admitted failure of the ethics committee to prevent the crapshow that is SCP-3000, and the whole thing where a dispute between the 05s and Ethics Committee led to open war (with gunfire, attack helicopters, and everything).
- Getting in on the Procedure 110-Montauk thing, one SCP-001 proposal has suggested that Procedure 110-Montauk may not be a necessary evil at all. Specifically...
Dr. Montauk, the researcher for which the procedure was named, came up with Procedure 110-Montauk after losing his brother and blaming it on the Children of the Scarlet King. The Foundation at that time had also captured SCP-231-7, the last of the child brides of the Scarlet King. So he came up with Procedure 110-Montauk as a torture procedure described as a phony research protocol in his darkest moment because he wanted to see SCP-231-7 suffer as much as humanly posssible, projecting his hatred at the Children of the Scarlet King as a whole onto an innocent child. A member of the Children of the Scarlet King notes that the fact that Procedure 110-Montauk works at all was a fluke, it was created out of a place of such hate, rage, and evil that it thaumaturgically resonates with the Scarlet King and keeps him contained.
As a result, Procedure 110-Montauk isn't evil because it works, it works because it is evil.
Regarding all the "good" things the Foundation has done, I'm reminded of this Doctor Who clip. And this one, when it comes to the question of "what is evil".
Even Dr. Clef (the writer, not the character), one of the lead writers for the Foundation, thinks the SCP Foundation is evil
So the Foundation are not "good guys". Many of their motivations are based on personal curiosity or gain, but they try to justify it as in the name of the greater good. They merely happen to align with the reader's moral compass in that they don't want to see the world destroyed, and aren't as wantonly destructive or naïve as the Global Occult Coalition or Are We Cool Yet? They are at best less bad, and sometimes outright worse, than the anomalies they contain, something that has been pointed out in several entries. Much like Warhammer 40k it's not that the Foundation is good, it's that everyone else is worse. It's really not possible to frame the Foundation as unambiguous good guys given they are depicted performing actions that are intended to be offensive to modern readers and are frequently treated as not being in the moral right even if one excludes "lesser of two evil" situations.