The dollar is the world currency and also the universal hard currency. Except the United States, which can print US dollars, other countries have to sell some goods and services to get US dollars, such as Filipino servants, Saudi oil, German cars, Korean cosmetics and so on. Either export directly to the United States for dollars, or export to other countries, and then these countries pay with the earned dollars. So in the end, all the dollars came from America. So when you see this, you should understand what foreign exchange reserves are. The dollars you earn from exports are foreign exchange reserves. Similarly, when you sell things to other countries (except the United States), people pay for them with their own foreign exchange reserves.
As for what foreign exchange reserves are used for? Quite simply, you must buy things from others in dollars, because dollars are hard currency. Then the dollars you use to buy things can only come from your foreign exchange reserves. You can't directly change RMB into dollars, because people don't accept RMB. As I said just now, the dollar is hard currency. In addition to the US dollar, gold is also a hard currency, so gold reserves are also part of foreign exchange reserves.