The maximum supply of slightly less than 21,000,000BTC, to be accurate max is 2,099,999,997,690,000sat, is directly correlated to the initial block reward of 50BTC and halving this value of 5,000,000,000sat after 210,000 issued blocks by a binary bit-shift.
The real question is: why 210,000 blocks between halvings? That's the choice that lead to a total of 21 million Bitcoins. Why not a round number of blocks? Say 100,000? Or 314,159 blocks? I guess the reason was to get 4 years between halvings. If that's correct, Satoshi chose 10 minutes between blocks, he chose 50 Bitcoin per block, and he choose to have halvings every 4 years. The 210,000 blocks and 21 million Bitcoin just resulted from this.