You'll nearly always see this at cricket matches. The bowler and fielders play a game of catch after each delivery, seemingly at random but especially after fielding a ball.
Why do they do this?
There's a few reasons I can think of outside of the "I'm just going to randomly chuck the ball at someone" that the ball may be passed between players between deliveries.
Make people feel "In the game"
Cricket can be a long ol' game if you're stuck in the field, and nothing is coming your way; especially in First-Class or Test cricket which can go on for 4-5 days. Sometimes you just want to feel the ball in your hands...
Keep the ball dry
In some playing conditions, whether there has been a bit of rain in the air or there is dew coming up on the field, it's imperative to keep the ball as dry as possible; a wet ball can impact the way a bowler delivers the ball. For example, a spinner wants to put as many revs on a ball as possible, in order to get the ball to spin - this is hard to do if the bowler can't grip it as well as they would like because it is wet.
In the case of passing the ball to each other - it's usually much safer to pass the ball in smaller throws between multiple players, than it is to risk throwing the ball further, and it hitting the ground and becoming wet.
Give it to the team's "Shiner"
This happens less-often in one-day games like ODIs and T20 games, but in First-Class or Test matches, giving the ball to your team's Shiner is a common thing.
A team's Shiner is in charge of trying to get the ball shinier on one side than the other. The purpose of this is to try and get the ball to swing in the air when it is bowled by the bowler. You'll often see the ball passed to a player, that will then rub the ball upon their thigh, or on the cuff of their sleeve, in between deliveries, in order to make that side shinier than the other.
They do this in baseball to just keep their arms loose. I would assume that Cricket players do it for the same reason.