Why only put 21 million units in the source code?
Are you sure there are 21 million units? i don't think so... As other users already mention, those 21 units is a tricky number because bitcoin has 8 zeros after the point, and that means the total units can be a lot more than 21 million.
Maybe your question is: Why limit the total of coins and not make the infinite? And the answer is - Because finite elements will always have a greater value than infinite elements. And 21M is a good number, isn't small or isn't big.