Some people have yen but want to buy things, like a tanker full of oil, priced in dollars. There once existed a specialized profession of very expensive middlemen who would facilitate this transaction. The transactional costs would have paid for a nice house. Computers can do it for a tenth the price, saving money for folks in the non-finance economy when they're doing things that the non-finance economy very urgently wants them to do.
Well, if someone wanted to buy something in another currency, they'd have to exchange their currency. This is done at a teller window for small transactions(you're going on vacation), but done on the exchanges for large transactions(someone wants to buy 100M USD in Oil with their Euros.)
Another common trade is turning foreign currency profits into your local currency to reduce exposure if that foreign currency is particularly volatile and/or the majority of your expenses are in your local currency.
Banks really just don't have that kind of money on hand. Nor should they, the forex market is trillions a day.
Before, these sorts of transactions were done via voice, but traders were using them to manipulate the fix rate[1][2]. Now, banks are taking humans and fraud out of the equation by just going from 100M transaction to algo.