Avengers: Endgame wouldn't be possible without every Marvel movie that came before it, which is kind of a beautiful thing. Crucially, Endgame wouldn't be possible at all without Ant-Man's ability to get really, really small. The great thing about movies like this is you can just have a smart character say some acronyms and use words like "entanglement" and "paradox" a lot, and to the average viewer who has agreed to suspend their disbelief for a few hours, that sounds plenty legit. But Endgame's biggest plot device is actually based on a real scientific theory.
Ant-Man's surprise arrival at the Avengers' secret picturesque headquarters introduces the remaining crew -- Captain America, Black Widow, Hawkeye, Rhodey, Nebula, Rocket, and the Hulk -- to the idea of time travel without needing the assistance of Doctor Strange (who was snapped) and the Time Stone (which was destroyed by Thanos after he'd accomplished his goal). Once they get Tony Stark onboard with the idea, and once Tony has a brilliant epiphany about how to do it, they build a time machine that transports each Avenger to one of three time periods when they knew the location of each Infinity Stone, so that they can bring them back to their future, make their own gauntlet, and snap half of all life back into existence.
Sounds easy, right? Well, no, it sounds pretty complicated, and the end result is more complicated still. They succeed in getting all the stones together, but at a cost: When Nebula journeys back in time to 2014 to retrieve the Power Stone on the planet Morag -- the same moment we met Peter Quill for the first time in Guardians of the Galaxy -- her brain circuits accidentally open a channel with the villainous past version of herself up in Thanos' ship, and she basically spills every possible bean. Thanos now knows that not only did he succeed in making his plan a reality, now his remaining enemies are working to undo it, and might even succeed. So, after bad Nebula switches places with good Nebula and messes with the time machine, Thanos follows the Avengers back to their present (which, in Endgame's time, is the year 2023) and wages a war he ultimately loses.