The writers did the wrong thing, but Joel did the right. Fight me. SPOILERS.
Under the literal circumstances given to Joel in the finale this season, every single kill he made was righteous, even killing Marlene after she was down.
Logically and from a purely scientific perspective he was right. The "save Ellie or save the world" conflict was forced. It made no sense in a series that otherwise has been so thoughtful and plausible about what a post-cordyceps world would be like, especially on a material, day-to-day level.
Having Marlene promise that their doctor could absolutely, for sure take Ellie's brain and make a cure that would absolutely work makes no sense, honestly. Just no.
At 2000's level technology, where that world is now frozen due to the collapse of civilization, it would've taken years to figure it out. Even at 2023 levels of technology, it would take years.
Also, they had a lot of tests they could've conducted. A BRAIN BIOPSY WAS COMPLETELY AN OPTION.
A dead brain is useless at telling anyone how it survived and what neurochemical processes were going on. Maybe Ellie's survival was mostly because she got infected in utero when her brain would've been at it's most undeveloped and ultra-plastic. Maybe it won't work for adults who's skull jello has fully set.
(BTW, it would've been a far more interesting ending if they did this. Brain biopsies, especially at a hospital operating on 10% capacity with doctors who may not actually be specialists in neurology or neurosurgery, comes with risks. Imagine if Joel went on his rampage because even a 50-50 chance was too high for him.).
Wasting the one source of information
Which leads me to reason two: the Fireflies cannot be trusted with the fate of the world.
The Fireflies are the weakest part of the writing in the series. American TV refuses to portray what successful resistance of authoritarian military regimes looks like. They either want it to be so implausibly sudden and easy that it defies logic or they want it to require badly strategized terrorism.
In-world, the Fireflies suck at their jobs. They've made shit all in the way of progress in all their years. Worse yet, their actions show they have precious little regard for the things they say they're fighting for. If they had their hands on the only vaccine/cure? They would 100% either abuse or squander it.
After all, Marlene did nothing to protect Ellie who she knew from day one of her life after mercy killing Ellie's mother. She just sort of let Ellie float off into the QZ. Then, when she does come across Ellie again, instead of leveling with her and trying to be kind to a traumatized teenage girl who's reactions are completely valid, she chains her up and is super shitty to her.
This is not a group of people who can be trusted with a cure.
And finally, reason three: morally the Fireflies were completely wrong.
Ellie had agency, and yes she could intellectually understand the decision given to her, but there's no way she could've consented. Not because of age or agency, but because she was not given sufficient time to process the choice or even talk to Joel - the one person who's had her best interests at heart above all else.
They didn't even give Ellie time to eat a few hot meals, catch up on sleep, get some clean clothes. There's no way Ellie or any other human being could be fully self-advocating in such a short time.
There was no time for her to consider that, realistically, there was no way the Fireflies would let her walk away from them and go back to the compound and live a peaceful life. Ellie knows what's what. There's no way she didn't know that surrender was the only real option.
And of course Joel absolutely knew that too when he shot Marlene. There's no way that Marlene wouldn't have initiated at vicious hunt for Ellie had she lived. Joel damn well knew Ellie would never be safe otherwise. And he was right to take action.
There's a reason we don't let living organ donors just sign some papers and speedrun into surgery the next day even if they really want to. It's why, when morally done, we require mental health screenings and time for them to fully comprehend the consequences beyond the medical - including the fact that they don't have to do this.
Just because someone offers something freely, even confidently, doesn't mean it's moral to accept it.
Marlene and the Fireflies owed Ellie not just medical information, but emotional information. Ellie couldn't have been emotionally or psychologically informed that quickly - especially not with her biggest source of support and safety being deliberately taken from her.
The Fireflies forced her hand. That's not okay.
Whether Joel thought of any of that or just couldn't handle losing Ellie, he did the right thing. Whether it was right for him to lie is another thing, but saving her life was right on all possible levels.