Foreigners who obtain dollars by selling goods to us can use them to buy our goods or to buy our assets (either physical or financial), i.e., to invest in our economy or simply hold our dollars. As you point out, if they buy our goods this improves the standards of living of all concerned by extending the division of labor to encompass more people in more places. If they invest in our assets, this too improves the standards of living of all concerned. The capital structure of the world economy is built up more fully. If they hold dollars, then we benefit in having higher purchasing power of our dollar than otherwise. In all cases, we benefit.