Production of hardware is some R&D, and then actual manufacturing. Production of each physical item costs you. Production of every physical item has a chance to go wrong. Production of each physical item requires a number of humans (often a large number) to do repetitive, high-precision, high-skill work, as fast as practical. You can augment or replace some of them with robots but it also costs you, and you can't replace all the humans with satisfactory results.
So, with hardware, the cost of the workforce plays a major role, while with software it does much less. To produce physical things, you need a lot of people who are not well-off, and for whom factory work is an upgrade of their financial and social standing. A "developing country", with huge swaths of population leaving rural life for a better city life and factory work, is best in this regard. Ideally you sell your product to richer folks, maybe outside the country of production.
Of course there can be situations where the workers are highly paid, and produce very valuable things through their skilled work. Ford in 1950s famously paid the assembly line workers very well, so that they could buy the cars they produce, and valued their employment. But this does not always occur; people doing work that does not add a lot of resale value also want to live well, especially if the society does not want a flood of immigrants who are willing to work for much less. Check out how much the work of a plumber costs in Switzerland. So only high-precision, high-margin, low-volume manufacturing remains in Switzerland, such as precision optics, precision industrial and medical equipment, or premium mechanical Swiss watches. The US is in a somehow similar situation.