I figured out in 2009, when I was working at a hedge fund trying to bid on the assets of bankrupt banks post financial crisis.
Basically, every branch loses money to gain depositors. All the fees on monthly accounts, safety deposit boxes, ATMs, cashiers checks, etc. do not offset the cost of the office and employees. However, if the loss is small compared to the volume of deposit money the branch attracts, then the bank headquarters has "borrowed" money at a very low cost.
I think a typical suburban Countrywide or Washington Mutual branch was losing about $100K/yr but had deposits of $20M; not bad at all considering Fed Funds had been around 5.25% until fall of 2007, and that having the capital was the life blood necessary to do all the profitable operations (originating mortgages, credit cards, student loans, EDIT: meet regulatory capital requirements, etc). In Midtown, those numbers might be multiplied many fold, so very few retail stores can compete and stay profitable.