As a nonresident alien, you will only be subject to US income taxes on your US-sourced income. As a resident alien, your global income is subject to US taxation. Still, some people elect to be treated as resident aliens for tax purposes in certain situations.
If you’re a nonresident alien married to a US resident, for example, electing to file as a resident allows you to jointly file with your spouse, which can help you save on taxes.