We've come a long way, you and me... We've seen a bunch of different kingdoms... I mean, sure, we got shot down and stuff along the way... But think of all those hats! This trip really was amazing. Thank you, Mario. It's been an honor walking a mile on your head.
Cappy is the main deuteragonist of Super Mario Odyssey. He is Mario's main ally throughout the game, and assists him in various ways. Cappy is originally from the Cap Kingdom and joins Mario in order to rescue his little sister, Tiara.
After Mario is knocked off an airship by Bowser while trying to rescue Princess Peach from him in the game's opening cutscene, he lands in the Cap Kingdom and loses consciousness from the fall. Cappy finds him and manages to make him come to, and tells him that in addition to Peach, Bowser has also kidnapped Cappy's younger sister Tiara, and suggests that he and Mario work together. Cappy then transforms into a replica of Mario's cap (the original was destroyed by Bowser) and aids Mario by allowing him to possess enemies and other creatures and gain access to their abilities, and he can also be used as a throwing weapon.
Even after Bowser is defeated and Peach and Tiara have been rescued, Cappy will still be available for Mario to use in the post-game. Right before the player completes the objective "Long Journey's End" in Darker Side, Cappy talks as if he is saying goodbye to Mario, but he will still be available for gameplay purposes, so as not to lock the player out of getting any Power Moons they haven't yet gained that require him.