you have to understand how strongly Microsoft marketed the Xbox when coming into the game industry
obviously the Gamecube did not really sell that well for Nintendo anyway, but with Microsoft pushing their system so hard it's natural they would sell a lot in the USA especially. and as others have mentioned, Halo was huge and arguably the sole reason the Xbox sold as much as it did
that said, Microsoft invested a tonnnnnn into the system and surely lost a huge amount of money to force themselves into the gaming industry. Nintendo was very profitable in that generation with the Gamecube and GBA despite not selling as many units as their competition