
The Last of Us Season 1 ended with Joel killing all members of the Fireflies inside St. Mary's Hospital in Salt Lake City, including Abby's father, Jerry Anderson, to save Ellie. Joel (Pedro Pascal) and Ellie's (Bella Ramsey) journey in Season 1 of Max's post-apocalyptic series mainly focused on reaching Salt Lake to search for the hospital run by the Fireflies (led by Merle Dandridge's Marlene) to procure a cure based on Ellie's immunity to the cordyceps virus.
After dealing with several ups and downs, the pair eventually reached the hospital, but Joel made a crucial decision to save Ellie after learning the truth about what the doctors would do to her to find a cure. Joel's controversial decision from the Season 1 finale carried over to The Last of Us Season 2, affecting his father-daughter relationship with Ellie because he lied to her and, ultimately, costing him his life five years later.
Why Joel Killed the Surgeon Doctor (And Practically Everyone In the Hospital)?

Joel's killing spree in The Last of Us Season 1, Episode 8 was because he learned from Marlene that the doctors were planning to perform surgery on Ellie to remove her brain and try to develop a vaccine, which would instantly kill her.
Given that Ellie was already in surgery by the time Joel learned everything, the only way to save her is for him to fight through the Fireflies in the hospital, killing everyone in his path, including Abby's father, Jerry Anderson. Joel shot Abby's father point-blank in the head to get to Ellie, without knowing who he was.

Bella Ramsey already defended Joel's controversial decision in The Last of Us Season 1 finale, saying, "There was no other option other than to save her:"
"I think she delved beneath the surface level meaning. I mean, don’t ask me if Joel made the right decision. I mean, I think Joel made the right decision. And I think most people agree. From the reaction to the series as well, more people are like, ‘he definitely made the right decision.' I don’t think it was even a choice. I don’t think it was a decision for him. There was no other option other than to save her. Because he didn’t…He did save the world, but like his world. That’s so cringy."
He then took an unconscious Ellie back to Jackson to stay there for good. However, Joel's actions greatly impacted his bond with Ellie since he didn't tell her what truly happened in Salt Lake.
The five-year gap between The Last of Us Season 1 and Season 2 implied that Ellie learned the truth from Joel (as evidenced by her exchange with Nora in Season 2, Episode 5), and this caused a rift between them that wasn't resolved until his final moments.
Joel’s Decision Launched a Cycle of Violence in The Last of Us

In The Last of Us Season 2, viewers are introduced to Jerry Anderson's daughter, Abby. Her crew consists of former Fireflies, who have become members of the Washington Liberation Front (WLF) in the five-year gap.
Abby made it her mission to track down Joel and kill him slowly for murdering her father in St. Mary's Hospital. She fulfilled her goal in The Last of Us Season 2, Episode 2, after she killed Joel in front of Ellie and an unconscious Dina.
Joel's actions of killing the Fireflies (including Jerry Anderson) essentially kickstarted a cycle of violence and brutal vengeance that led to Abby's quest for revenge, and now, Ellie's path of finding Abby to seek retribution for her actions (read more about Abby's whereabouts following Joel's death in The Last of Us Season 2).
While it is indeed brutal, there is only one way for this cycle of violence to end, and it all boils down to Ellie's decision to put a halt to it and recognize the necessary steps to heal and move forward. However, it is easier said than done since Ellie is currently on a violent path and slowly leaning toward a point of no return.