Captain Marvel: What Does The Ending Really Mean?
5. The Tesseract Is With S.H.I.E.L.D. - And Links Captain Marvel To Thanos
The Tesseract not only makes a surprise appearance in Captain Marvel, but ends up serving as the MacGuffin of the plot, as it's this device both the Kree and the Skrulls are searching for as it's hidden away on Dr Lawson's laboratory (which is under a cloaking device and floating in space, of course).
The Tesseract, it turns out, was what powered Lawson's energy-core, which is why the Kree are so keen to get their hands on it, as it would give them access to an incredible power source. What's more, though, is that it's revealed the energy-core blasted Carol Danvers when she and Lawson crash-landed from space, at which point Yon-Rogg killed Lawson (who was secretly Mar-Vell but working on Earth) and took Danvers back to Hala, infusing her with his own Kree blood and turning her into a soldier.
That means that Captain Marvel was created by the Tesseract, or in other words, her powers come from the Space Stone itself, but seemingly aren't dependent on it in the same way Vision was the Mind Stone. That gives her a major link to Thanos, since he currently possesses the Stone, and will help her going up against him, since it gives the Avengers an Infinity Stone-powered hero to bolster their ranks.
As for the Tesseract itself, when both the Kree and Skrulls discover the laboratory, it's unceremoniously hidden in a Fonzy lunchbox, and then Goose - revealing its true, tentacled form - swallows it to keep it out of the clutches of the Kree. In the post-credits scene, we see Goose climb up onto Nick Fury's desk and spit up the cube. This does fit within the timeline we've been given: we know that Red Skull previously had it, and it then was dropped into the ocean, before being retrieved by Howard Stark. There's still a sizeable gap after that, but at some point Mar-Vell/Dr Lawson started working at S.H.I.E.L.D. and discovered the Tesseract, using it for her own mission some 6 years before the events of Captain Marvel. Now it's back in S.H.I.E.L.D's possession, where it'll stay until Thanos sends Loki to take it for him.