From the Super Mario Wiki
The Helmet is an item in the game Super Paper Mario. When Mario reaches Outer Space, he isn't able to breathe, and thus sets out on a quest to get something to solve this problem. While doing this, Mario comes across Pook, who gives him his Goldfish Bowl. After dumping out Pook's pet goldfish Captain Gills into the sewers, Mario uses it as his helmet in space. If the player refuses to put the Helmet on enough times upon re-entering Chapter 4-1, they will get a Game Over.
A helmet also appears in Super Mario Sunshine. During certain missions in Noki Bay, Mario borrows a helmet from the Noki Elder's Grandson. While equipped, it prolongs Mario's ability to stay underwater without returning to the surface to breathe. Though Mario's Health Meter runs out considerably slower when this helmet is used, he must still collect Coins to replenish it when it gets low.