Rewards are given out in bundles equal to the number of balls you receive minus 1 (because they added one extra ball to the default number during the last-ball bug debacle).
So you get more chances at good rewards at a gym your team controls, if you raid in a group with other members of your team, and in smaller groups that give you more time for personal damage contribution.
https://thesilphroad.com/science/raid-rewards-secret-multipliers
The good rewards were diluted when they flooded the reward pool with potions.
https://www.reddit.com/r/TheSilphRoad/comments/76xlv5/reward_bundles_image_updated_with_potions/