The more people move goods, the thinner the gap
Apples sell for 2 yuan a kilogram where they're grown and 6 yuan at the wholesale market in the provincial capital, and freight works out to 1 yuan a kilogram. The first few trucks make 3 yuan a kilogram after costs, and soon there are many more of them. With more apples in the city, the price there falls; with more people buying where the apples are grown, the price there rises. Once the city price has fallen to 4.5 yuan and the growing-area price has risen to 3.5, the gap is only 1 yuan, just enough to cover freight. One more truck would lose money, so nobody adds one.
The cost of moving goods is the floor under the gap
If freight is 3 yuan a kilogram, the gap can be pushed down to 3 yuan at most; at 5 yuan, the 4-yuan difference between the growing area and the city won't draw a single truck. The trouble of finding out prices elsewhere counts as a cost of moving goods too. Before the Kerala fishermen had phones, that trouble was so great that nobody would go to another beach to sell; phones cut it to almost nothing. Whoever moves goods most cheaply gets the money in the gap. If a rival gets costs down to 0.6 yuan, the gap is pushed down to 0.6 yuan, and a fleet whose costs are 1 yuan loses 0.4 yuan a kilogram and has to stop.
The gap is only locked in when both sides trade at once
The safest arbitrage is to sell the same thing where it's dear at the very moment you buy it where it's cheap. The difference is in your pocket on the spot, and wherever prices go afterward has nothing to do with you. If you've bought only one side and are waiting for the price on the other side to rise, that isn't arbitrage but a bet: while you wait, the gap may widen first, and what you're holding may fall. Hauling apples takes a day on the road, and used books have to wait for a buyer; both include a stretch of waiting like this, and the risk carried during that wait counts as a cost of moving goods too.
A price gap holds up least when the same thing can be traded at any moment in both places and moving it is cheap: foreign exchange rates, gold prices, the shares of one company on two stock exchanges. When two things are only similar and not the same, such as two companies in the same industry, the gap may not close and can keep widening, because one company's shares can't stand in for the other's. Counting it as profit just because something is cheaper elsewhere is another mistake: if your money is tied up in goods for weeks before it comes back, and you leave those weeks' risk out, there's little of the difference left by the time it reaches you.