Major spoilers for Captain Marvel ahead. While Captain Marvel doesn't exactly lay down a clear-cut path that explains how the surviving Avengers can un-do Thanos' dusting of half the population in Infinity War, it does provide a big, juicy hint. By the end of the movie, it seems like a given that the Tesseract will be important to Avengers: Endgame, and fans online are already formulating their theories about how.
Per Time, the full list of the movies which feature the Tesseract includes Captain America: The First Avenger, Thor, The Avengers, Thor: Ragnarok, The Avengers: Infinity War, and now Captain Marvel, in which it's first referred to as an "energy core." It comes into play because Carol Danvers' (Brie Larson) mentor, Dr. Wendy Lawson (Annette Bening) — who was really a Kree named Mar-Vell working undercover — had used the Tesseract cube's energy in her work on Project P.E.G.A.S.U.S. At one point, Carol pilots the jet for Mar-Vell to go retrieve the Tesseract from her laboratory orbiting the Earth when Yon-Rogg (Jude Law) shoots them down. In order to stop Yon-Rogg from getting the Tesseract energy powering the jet, Carol shoots the engine and she's blasted by the energy shock, which runs through her body. Redditors have pointed out that this means that Carol likely has Tesseract power, a fact which the Kree tried to hide from her. And it could explain her role in Endgame.
The power from the Tesseract comes from the Space Stone, which is one of the Infinity Stones that Thanos collected in Infinity War. The Space Stone allows the bearer to create portals throughout the universe, according to Time, and with that you can travel from one portal of space to another. Now, that is likely how Captain Marvel appears in the Avengers' headquarters in the mid-credits scene after Captain Marvel, as The Wrap suggests. But the Tesseract that you see in Captain Marvel could also show up in Endgame in another way, too.
As Time reports, many fan theories posit that the only way the Avengers can defeat Thanos is to travel back in time to collect each of the Infinity Stones and undo the damage which Josh Brolin's character caused. Perhaps Goose storing the Tesseract in the '90s will allow some of the time-traveling Avengers to meet the Flerken and retrieve the Space Stone.
Alternatively, Goose's Flerken ability to store entire universes in its mouth, as pointed out by Esquire, could prove to be an even greater opportunity for the Avengers in Endgame. The cat-like creature could even have the ability to duplicate the Tesseract, given the Avengers another advantage in the fight against Thanos.
Exactly how any of this might happen, especially with Goose back in the '90s, is still unclear. But the post-credits scene at the very end of Captain Marvel shows the Flerken hacking up the Space Stone receptacle, which is another indication that it'll be the key to reversing the snap. Carol Danvers may be the most powerful Avenger, but Goose could be her most necessary resource.