First the game splits u based on the device u are playing on; Apple vs everything else. Up to a point level matters (maybe 100) at different break points. The other conclusive evidence is based on ur raking in the last leaderboard. It doesn't seem to care how many points u got, just the rank u finished at. I get put into a group with many people that had previously won the last leaderboard (they have trophies or the prize dragon). The rest is luck. I've been in groupings where some have no gold dragons or 3 roosts or one Evo temple, so I don't think these factor into what group u end up in. Trophy displays are also spotty in my group. One has a lot and only recently started losing some leaderboards. Other have checkered history when I scan for prize dragons. I think only the last or recent wins are counted.
I'm not sure if ur food or gold counts are factored in. I noticed a few players in my group seem to have a strategy around food. One has an insane amount of bomb producing dragons. Something like 10 maybe. So I know there's a chance there will be a big food fight at the end, and am so totally prepared with my millions of food! Maybe I'll finally get to feed light mother and glasswing to 15