How did Moshe determine which firstborn were covered by the Levi'im and which ones had to pay the five Shekalim?
Rashi: On 22,000 pieces of paper he wrote 'ben Levi' and on 273, 'five Shekalim'. All of these he mixed and placed in a box, and every firstborn picked one.
Rashi writes that on 22,000 lots Moshe wrote 'ben Levi' and on 273, 'five Shekalim'. Every firstborn picked one. Still, they will complain. Everyone will want to take first, when all lots of 'Ben Levi' are there! The latter can say 'presumably, the first will pick Ben Levi', for they are the majority!'
Moshav Zekenim (46) citing Ri: Each Bechor returned his lot to the pile after he showed Moshe what was written on it. 1 Riva (11:26) says so about the lottery to pick members of the Sanhedrin.
Moshav Zekenim (46, citing his Rebbi) #1: Moshe divided the notes of 'Ben Levi' among several chests, and a group of Bechoros would each take one from a chest.
Moshav Zekenim (46, citing his Rebbi) #2: Hashem told Moshe who must redeem himself. The lottery was merely to assuage them. Moshe let them pick first, and each picked a note of 'five Shekalim.' 2
Rosh: Rashi explained according to R. Yehudah. R. Nechemyah says, for each Bechor there was a note saying 'Ben Levi', and one saying 'five Shekalim.' In theory, all could have picked 'Ben Levi', or all 'five Shekalim', or any combination. Through a miracle, exactly 273 picked 'five Shekalim.' Some say like this regarding the lottery to pick members of the Sanhedrin (Riva and Moshav Zekenim, on 11:26).
Riva (11:26) #1, Moshav Zekenim (11:26): The last ones cannot complain, for the former can likewise say 'presumably, the undesired lots will fall among us, for we are the majority.'
Riva (11:26) #2: There were as many desired lots as the total number of people who picked, so everyone had a chance to get his desire; there were only two undesired lots (regarding the Sanhedrin, and 273 regarding the Bechoros).
Moshav Zekenim: This is difficult. If so, it would suffice to have one note 'Ben Levi', and one ''five Shekalim'! (Via Hashgachah, 273 Bechoros will pick the latter.)
Moshav Zekenim: If so, it would suffice to have 2,000 or 3,000 notes of 'Ben Levi'! (Since all 273 Bechoros picked notes of 'five Shekalim', this was clear proof that Hashem told Moshe who must pay.)