In the beginning, Satoshi Nakamoto offered 50 bitcoins for each block created and that development happened in every 10 minutes.
Since there are 1440 minutes (24×60) in every day, that means that 144 blocks were created so 144X50 = 7200 bitcoins per day, 4 years are 1461 days which include the leap one) and the total bitcoins for the 1st 4 years came out to be 1461 X 7200 = 10519200.
After that, it was decided that every 4 years henceforth would decrease the bitcoins awarded per block created to half of its original value, the total bitcoins are 10519200 *(1 + 1/2 + 1/4+1/8 +
+1/2^n) = 10519200 *2 = 21038400 (if we take approximate of 1+0.5+0.25+0.125+.. = 2 )
That is why 21038400 is the theoretical limit and we dont want to go forever mining a millionth, a trillionth of a Satoshi. Actually (as for now) we cannot go less than 1 satoshi anyway. So the real number is just a little bit smaller than that, maybe 21038399.99999999 or 1 Satoshi away from the theoretical calculation.
I read somewhere