The major reason for this is that the US dollar is what is called a "reserve currency." This is a currency that is kept by many foreign governments as a large part of their supply of foreign currencies.
Governments like to keep reserves of foreign exchange for various reasons. They like to keep these reserves in currencies that are most likely not going to go down in value. For this, they want the currencies of countries that are economically strong and stable. Over the last 60 years or so, the US dollar has been the world's main reserve currency because the US has been prosperous and stable.
Because the US dollar has tended to keep its value well, other countries' governments like to hold it as part of their foreign reserves. This is why the majority of US currency is held outside the country.