The backstory to the game is that the Kocos are actually an ancient race of aliens who look like Chaos, and were in possession of the Chaos Emeralds. They're wiped out by some eldritch being known as 'The End', so as a last ditch measure to preserve their species they travel to Sonic's world, attracted by the Master Emerald, and settle on the Starfall Islands and create the Titans to fight The End. The Titans are powered by the Chaos Emeralds, and they are only partially successful - they seal The End in the final Titan (Supreme), and devolve into the Kocos.
It's implied that they continued to further devolve/mutate into the Chao.
Now, picking up from where Sonic Frontiers starts after its opening cutscenes, Sonic wakes up on the Starfall islands after escaping Cyberspace. A mysterious voice tells him he's broken 'the first seal/lock' and that he's the 'key'. You'd find out later that it's The End talking directly to Sonic, you can see the influences from Shadow of The Colossus.
Sonic and Amy's relationship builds up throughout the story, there's barely any interaction between Sonic and Tails. There's a good number of interactions with Sage, too, but you have to spend Heart Tokens to unlock interactions with any of the four.
As Sonic defeats each Titan and goes about the islands, he's also corrupted with each Titan he destroys, due to The End's energy or something. Hence why his arm's glitching out in the trailers.
Amy understands the Kocos, but she's trapped in a half-real/half-cyberspace existence, so Sonic helps her reunite the Kocos. There's 4 or so 'main' Koco characters they reunite; a mother and child, and two lovers - all four die with each reunion.
With the demise of the final Titan, Supreme, The End is released from her prison and escapes to space to gather her strength. However, Sonic is fully corrupted by The End's energy and is frozen in place, his body turning a dark pulsing red. With the same 'you've got this sonic/you're me hero' spiel from Forces or Generations from his friends, he breaks free and is back to normal.
At this point, Eggman's recognised Sage as a true daughter, and bids her well as she works with Super Sonic to destroy The End. Sage takes control of Supreme, piloting it into space.
Here's where it feels a bit like Dead Space. The End now becomes a giant celestial body, the size of a small moon or one of those asteroid levels from SA2. If you aren't playing on Hard difficulty, the bossfight ends with a QTE where Sonic skewers The End, causing her to explode and release massive amounts of energy. Sage saves him, shoving him aside and sending him tumbling back to Earth, whilst she dives into the explosion and somehow contains it.
On Hard difficulty, there's a final phase to the bossfight where you play as Sage, except it's a shootem-up from a top-down perspective. It's an interesting change of gameplay, but some of the previous games have done that before. Also The End actually has dialogue in this section, your typical 'I am stronger than every other god you've defeated before' schlock, with simultaneous male and female voices speaking. A few choice snippets.
"You have fought machines and gods before. They were finite, I am infinite, I am nothing..."
"Everything has fallen to me except the teeming Chaos of creation"
Sonic is safe and reunites with his friends, everything's great as they cheer and celebrate, watching as pieces of The End/Sage fall to earth as shooting stars (hence Starfall Islands). It cuts to Eggman being alone, rather depressed as he reaches out to the sky and pulls back his hand. After that, team Sonic flies back home.
The credits roll, with alternate songs depending on if you played on hard or not. Vandalise first plays, and then Family Born of Love plays on non-hard difficulties.
If you played on Hard, you get One Way Dream, sung by e-celeb NateWantsToBattle.
As you'd expect, the post-credits scene has Eggman retrieving a backup of Sage from the Starfall Islands cyberspace, her icon appearing on his computer screen. Her 'icon' is that 'zap' looking logo that's been in all of the marketing material of Frontiers. That symbol is just a representation of her face - her fringe and her one visible eye.