One of the biggest questions fans had going into Avengers: Endgame was: How is Marvel going to end the story of Steve Rogers? His heroic demise at the hands of Thanos had been a popular prediction for years, but that's not where the Russo brothers wanted to take the character. It's a good thing, too. They cruelly considered decapitating the guy, which would push fans (namely yours truly) beyond incredulity and into complete denial.
Anyway, there are multiple routes Kevin Feige and the Russos could've taken, but they decided on one that felt fitting for Cap in his current emotional state. After beating Thanos, saving the universe, and burying Tony Stark, Steve Rogers returns the Infinity Stones to their respective spots in history and stays in the past with Peggy. Understandably, his friends in the present freak out when they realize something is wrong. Spotting an elderly Steve sitting by a nearby lake, Bucky quietly tells Sam Wilson to go see him. That's when Steve passes the shield to a shocked Sam, who eventually agrees to continue fighting for what Steve spent so many years protecting.
During an interview with Kevin Polowy of Yahoo Entertainment, Bucky actor Sebastian Stan said that, if you consider his character's arc in the MCU, having Bucky become Captain America wouldn't feel right. Sure, it happened in the comics, but the MCU has had no scruples about changing up origins, scrapping histories, and building characters from scratch. Even an event as game-changing as a passing of the shield needs retrofitting, and Marvel made sure that any changes they implemented served the story they strove to tell.
Here's what Sebastian Stan said in response to the idea that the decision for the next Captain America could've gone either way, to Sam or Bucky:
Not really though, if you think about it. It makes no sense for him to -- why would you give it to the guy that's been trying to have a whole new history outside of the thing he's been trapped by? I remember on the day I found out [about Falcon getting the shield] when we were shooting, I was like, 'Oh wow, this is the deal.' But it makes sense. He [Sam Wilson] actually has been his [Captain America's] right-hand for a long time at this point. If you think about the movies and the time.
Anthony Mackie, who plays Sam Wilson, chimed in, saying:
And we're only one movie away from [Bucky] trying to kill everybody.
Oh, and if you missed the film's recent re-release, you probably disappointed Mark Ruffalo. Just saying.