The actual cause of the end of the world is ambiguous, but its effects are not. The animals are gone — Sam Weldon (Margaret Qualley), a teenager, laments that she's never seen a swan. Most of the humans are gone, too. They're either dead, or transported to a space station orbiting Io, one of Jupiter's moons.
Not everyone has fled, though. Sam, the daughter of a scientist (Danny Huston) who searched for the possibility of sustaining life, is one of the few humans left on Earth. She lives in high-altitude valley in a pocket of clean air, allowing her to go outside without a mask. Despite the fact that her boyfriend, Elon, lives on the space shuttle, Sam seems stubbornly committed to staying on Earth and continuing her late father's work. Already, she's made progress: She's found evidence of anaerobic bacteria breeding, proving living creatures have adapted to the new conditions of Earth.
But the very last space ship to Io is leaving imminently. Sam, realizing she doesn't have enough oxygen to get to the launch site, is resigned to stay in her little tranquil corner of a changed Earth. Remember, Sam's been led to believe this is the most noble path. As her father intoned on TV's last-ever news broadcast, "Planet Earth is a miracle in the universe. We are its caretakers. It is our duty to stay and fight for our world. Humans may have nearly destroyed our home, but we can make it habitable again. We will breath the air again. The strong, brave souls that will stay will become a civilization of its own design."
Then, Micah (Anthony Mackie) swoops in in a literal hot air balloon, complicating Sam's plans to stay. Like Sam, Micah remained on Earth when the rest of the population fled. Listening to Sam's father's hopeful transmissions of his scientific progress, Micah believed that Earth could once again sustain life. Micah wants to survive. As he reveals later on, he wants to survive so badly he let his wife starve so he could have more rations.
After learning Dr. Walden died, Micah's hope for life on Earth is extinguished. It's Io or bust, and he's determined to take Sam with him to the launch of the last Exodus ship. The late Dr. Walden seems to agree with Micah. Appearing to Sam in a vision, he warns Sam of her solitude, and says that human connection is ultimately more important than science. So, she agrees to board Micah's hot air balloon and leave the only place she's ever called home. After all, Elon is waiting on a ship near Io.
Or is he? The movie shifts dramatically after Elon delivers the news that he's joining a mission to find a new home planet, insinuating that he and Sam likely won't ever meet again. With that, Sam decides to act on the subtle sexual tension between her and Micah. They sleep together. Before the act, Sam cryptically says, "We have to." More on that later.
Before they can leave for the newer, farther launch site, Sam and Micah have to make a dangerous mission to collect more helium from inside the Zone, where all the air is toxic. As they wind down the roads on their ATVs, we can literally see a clear boundary between where the toxic air ends and the clean air begins.
Sam, standing in an art museum in the Zone, seems to balk at leaving Earth. She reads William Butler Yeats' "Leda and the Swan," which describes the mythological prelude to the Trojan War. Essentially, Sam is both wistful of humanity's accomplishments (art and poetry) and aware that such accomplishments often go up in flames (Troy and the current moment). Abruptly, Sam chooses to stay. She decides to believe in the possible reality she saw in a recurring dream: She can breathe in this new world. So, Sam pulls off her oxygen mask.
What happens afterwards is ambiguous. The scene immediately cuts to the future. Sam narrates a letter to Micah, who is ostensibly on an Exodus ship. First, Sam lays out her reasoning for staying: "The fascination for other worlds could not turn me away from the beauty of our home," she explains.
For all the Earth-lovers out there, Sam delivers a positive message. She is standing near the ocean – a place she's never been before. "Tell them it feels good. Tell them the dark clouds have given way tot he ocean mist. Tell them a new world awaits us. Tell them we're waiting for you to come back," she says. As she's speaking, a child runs up next to her, ostensibly her child with Micah — the "human connection" her father said was the most important thing on Earth (though we can only imagine the Handmaid's Tale-esque solo birth scene).
Essentially, Sam's theory proved correct. Either humans have adapted to the new Earth or the poison smog drifted away, and Earth healed itself. Either way, Earth is now habitable — and Sam is the only one left to deliver the message.
Alternatively, this sequence could also indicate that Sam passed away in Micah's arms after taking off her mask. The ending sequence has the hazy quality of a dream, which is where Sam's theories originated. Plus, the logic of the sequence doesn't really add up. Sam had previously indicated her house isn't near the ocean. How could she get back to her computer and send a message to Micah? Further, only Elon possessed the rigged computer capable of sending messages to Earth, and he's long gone. That said, IO never thoroughly explained what had happened to Earth — why would the movie suddenly incorporate logic at its end?
Ultimately, IO's ending is up to your interpretation. If you're an optimist, then the Earth conveniently healed itself after only a few years of catastrophe (by that logic, global warming is nothing to fear). If you're a realist, then Sam should've boarded that ship to Io and left Earth behind.