Quoted prices to buy and to sell differ, and the gap is not arbitrary. It compensates whoever is providing the quotes for two distinct risks they take on.
Continuous quotes require inventory
A market maker undertakes to buy and sell at published prices, which means holding positions until an offsetting trade arrives.
Holding inventory carries the risk that its value moves before it can be offloaded, and it ties up capital that has a cost.
The spread is the compensation for accepting that exposure across many transactions. No individual trade is expected to be profitable; the margin has to work across the whole flow.
Inventory that builds up on one side is also a directional position nobody chose to take. Managing it back to a neutral state has its own cost, which the spread must also cover.
Informed traders are the second risk
Some counterparties trade because they know something. A market maker cannot distinguish them from those trading for unrelated reasons.
Every trade against an informed participant is one the market maker loses, so the spread must be wide enough for gains from uninformed flow to cover those losses.
This is why spreads widen sharply around announcements, when the likelihood of informed trading is highest.
Volume and volatility set the width
Heavily traded securities allow inventory to be offset quickly, reducing holding risk and permitting narrow spreads.
Thinly traded ones require positions to be held longer and are harder to hedge, which widens the quote.
Volatility works in the same direction, since larger potential price movement during the holding period increases the risk being compensated.
Competition compresses the gap
Where several participants quote the same security, each has an incentive to improve on the others to attract flow. Spreads narrow toward the cost of providing the service.
Electronic trading intensified this, which is why quoted spreads on liquid securities have narrowed considerably over the past decades.
Where a single participant dominates or activity is sparse, the compression does not occur.
What the spread costs a trader
Buying at the offer and selling at the bid means starting each round trip behind by the width of the spread, regardless of what the price does afterwards.
For infrequent transactions this is minor. For frequent trading it accumulates into a significant and often unnoticed cost.
Because it is embedded in the price rather than itemised, it does not appear alongside commissions and is easily left out of any cost comparison.