There are a variety of theories as to what goes on inside of the Pokeball.
1) The Pokemon gets converted into energy/data.
2) The environment theory, where the inside of the ball is a recreation of the Pokemon's ideal environment to live in.
I prefer to believe a combination of the two. To fully understand where I stand on this, you need to have watched the Moriarty story arc of Star Trek the Next Generation. I believe that the Pokemon is converted to energy/data and placed in a simulation of its ideal environment. That way, there is no limitation on how large the environment can be (versus the volume of the ball) and the Pokemon can be happy.
This also allows for the Pokemon to be able to accept commands from inside the ball, and even move the ball itself. It can even deploy/release itself if necessary.
Let's talk about Deoxys. Or not, let's actually talk about Destiny Deoxys, the film. It is implied that when trainers visit LaRousse City, they surrender control of their Pokeballs to some sort of central system. Either that, or the system becomes a necessary component in the operation of the ball for the duration of the trainer's visit. This makes sense given the large battling organization on the island. Highly regulated.
How this relates is that perhaps Pokeballs are way more sophisticated than we imagine. And I think that's great.