In short, the longer your Pokémon is in a Gym, the more PokéCoins you will earn. However, you can only earn a maximum of 50 PokéCoins per day, even if all Pokémon are removed from all the Gyms you are defending at once.