According to the anime, Pokémon can survive for years in a Pokéball, and are fully conscious. Pokéballs are also a place where they can rest. However, Ash was once concerned that his Pokémon would freeze inside their Pokéballs. This indicates that while Pokéballs seem to be able to sustain Pokémon for a considerable amount of time, they can still risk freezing to death.
The video games do not explore this, so we're going to have to rely on the anime.
Ash was concerned that his Pokémon would freeze to death in their Pokéballs
In "Snow Way Out!" (which was aired as an unnumbered special episode, since it was rescheduled due to the Porygon incident), Ash was separated from Misty and Brock in the snowy mountains. After building a snow cavern, the Pokémon try to stay warm around Charmander's tail, but he is clearly tiring out from keeping it strong enough to keep everyone warm. Ash wants him to rest in his Pokéball.
Ash: Your flame's all used up! Come on, get back in your Pokéball and rest!
Charmander: (nodding his head no, but sounding exhausted) Char…maaan!
Ash: Come on! You have to conserve your energy! (Ash recalls Charmander) Come to think of it, the Pokéballs ought to be pretty warm. (To Squirtle, Bulbasaur, and Pikachu) Okay, you're going into your Pokéballs!
(The Pokémon voice their disagreement, not wanting to leave Ash alone)
You have to! It's a lot warmer inside the Pokéballs than out here in the cold. (Recalls Squirtle and Bulbasaur)
Pikachu refuses to go in his Pokéball (which he hasn't been in since the first episode). They huddle for warmth for some time before Ash looks at the Pokéballs on his belt.
I hope my Pokémon are warm enough. (He wraps the Pokéballs into his outer shirt)
That should help!
So it's clear that although Ash believed the Pokéballs would be a place they could rest, and that it would be warmer inside, that they would still be in danger from the cold weather.
Pokémon can survive for years in a Pokéball kept in relatively safe conditions
In "Two Degrees of Separation" (Diamond & Pearl Episode 2), James returns to ones of his childhood homes and finds a box containing his first bottlecap collection (Meowth says that whatever is inside is older than him). James is surprised to find that it also contains a Pokéball for the Carnivine he played with as a child, which he had lost. He sends out Carnivine expecting him to be just fine, and he is. It's very unlikely that anybody let Carnivine out since James lost it.
Similarly, "Sandshrew's Locker!" (Diamond & Pearl Episode 47) involved Ash and his friends helping out a girl named Mira recover her Sandshrew, whose Pokéball is underwater. She lived in the town until a nearby dam broke and flooded it. The team scuba dives and goes relatively deep before they find it. So the Pokéball seems to also be waterproof and resistant to pressure. It's a bit unclear how long the Pokéball was underwater, but I'm going to guess that it was several weeks minimum, given that the townspeople are long gone and Mira has resorted to tricking passerby to help her.
Also, it's very clear that Pokémon do not go into stasis or get transformed into data when they go into Pokéballs. They seem to have some awareness of the outside world and can come out of their Pokéballs at appropriate times (we see this most often with Team Rocket's Wobbafett coming out to say his line in their motto, but also Misty's Psyduck when she intends to call out another Pokémon). Also, the audience occasionally sees a Pokémon sitting inside of their Pokéballs, fully conscious, such as Iris' Dragonite.
How can a Pokémon survive for years in a Pokéball without food, water, air, or exercise, yet still be conscious of the outside world? Never explained, unfortunately.
The show never explores if Pokémon can
die leave this world while in the Pokéball
The anime hardly ever touches death (and often softens references to it with phrases like "be destroyed" or "leave this world"). Heck Lavender Tower, which is a Pokémon graveyard in the games, is just a haunted house containing three ghost Pokémon who act like the Three Stooges.
The only episode that I'm aware has addressed death is the 2017 Sun & Moon episode "One Journey Ends, Another Begins...". However, the Stoutland that died was a wild Pokémon, so it doesn't provide any insight into what happens to a captured Pokémon that dies.
Given that we've never seen a captured Pokémon die inside or outside of a Pokéball, we don't know for sure if they can die inside. The closest we got is Ash fearing that his Pokémon would freeze to death while in their Pokéballs, which suggests that it is a risk.