It primarily comes down to: How many games does Nintendo themselves own the license and distribution rights to?
Certainly more than 30. I can see perhaps not 300, although would not at all be surprised if it was.
Those are basically "free" so far as Nintendo has to pay anyone for rights to.
Then looking at the selection of games included already on the thing, we can at least determine publishers that are willing to license out their games to Nintendo.
Yes these games will each have a per copy sold royalty Nintendo must pay, but on the same token this is Nintendo, and it should be clear to anyone the demand this thing has on the market.
At that point it's just a matter of arm wrestling between them to determine a price.
So sure, they can't put on it every game (there's only just over 10000 in existence, this isn't a storage capacity problem)
As you say, they can't even include all popular games.
But they certainly could have done better than they did for no extra cost to them, and much better than they did with said cost.
The former is the confusing "WTF nintendo?" question.
The latter is only a question of how much they would need to sell the unit for to pay for everything on it and still make a profit. And I've no doubt in my mind that they would still sell at least some.
I mean paint the thing zelda cart gold, only release 1000 numbered units, and sell it for a thousand dollars. They would still sell out just as fast as the current units on the market did, and that's a "worst case" situation (for the customers that is)
But they certainly have all the data needed to know what that would cost them, what they can sell it for on the market, and roughly how many would still easily sell.
All they had or have to do is build the things.