I understand that the bid-ask spread is the difference between the price a buyer is willing to pay and the price a seller is willing to take for an asset. I also understand that this difference goes to the "market maker". Who is this market maker? To me it seems like this would be the exchange. Is it ever the case that the market maker is the exchange? If not, who is it?
Joke warning: These days, it seems that rogue trading programs are the big market makers (this concludes the joke)
Historically, exchange members were market makers. One or more members guaranteed a market in a particular stock, and would buy whatever you wanted to sell (or vice-versa). In a balanced market -- one where there were an equal number of buyers and sellers -- the spread was indeed profit for them. To make this work, market makers need an enormous amount of liquidity (ability to hold an inventory of stocks) to deal with temporary imbalances. And a day like October 29, 1929, can make that liquidity evaporate.
I say "historically," because I don't think that any stock market works this way today (I was discussing this very topic with a colleague last week, went to Wikipedia to look at the structure of the NYSE, and saw no mention of exchange members as market makers -- in fact, it appears that the NYSE is no longer a member-based exchange).
Instead, today most (all?) trading happens on "electronic crossing networks," where the spread is simply the difference between the highest bid and lowest ask. In a liquid stock, there will be hundreds if not thousands of orders clustered around the "current" price, usually diverging by fractions of a cent. In an illiquid stock, there may be a spread, but eventually one bid will move up or one ask will move down (or new bids will come in). You could claim that an entity with a large block of stock to move takes the role of market maker, but it doesn't have the same meaning as an exchange market maker.
Since there's no entity between the bidder and asker, there's no profit in the spread, just a fee taken by the ECN.
Edit: I think you have a misconception of what the "spread" is. It's simply the difference between the highest bid and the lowest offer. At the instant a trade takes place, the spread is 0: the highest bid equals the lowest offer, and the bidder and seller exchange shares for money. As soon as that trade is completed, the spread re-appears. The only way that a trade happens is if buyer and seller agree on price.
The traditional market maker is simply an entity that has the ability to buy or sell an effectively unlimited number of shares. However, if the market maker sets a price and there are no buyers, then no trade takes place. And if there's another entity willing to sell shares below the market maker's price, then the buyers will go to that entity unless the market's rules forbid it.
A "market maker" is someone that is contractually bound, by the exchange, to provide both bid and ask prices for a given volume (e.g. 5000 shares). A single market maker usually covers many stocks, and a single stock is usually covered by many market makers. The NYSE has "specialists" that are market makers that also performed a few other roles in the management of trading for a stock, and usually a single issue on the NYSE is covered by only one market maker.
Market makers are often middlemen between brokers (ignoring stuff like dark pools, and the fact that brokers will often trade stocks internally among their own clients before going to the exchange).
Historically, the market makers gave up buy/sell discretion in exchange for being the "go-to guys" for anyone wanting to trade in that stock. When you told your broker to buy a stock for you, he didn't hook you up with another retail investor; he went to the market maker. Market makers would also sometimes find investors willing to step in when more liquidity was needed for a security. They were like other floor traders; they hung out on the exchange floors and interacted with traders to buy and sell stocks. Traders came to them when they wanted to buy one of the specialist's issues. There was no public order book; just ticker tape and a quote. It was up to the market maker to maintain that order book.
Since they are effectively forbidden from being one-sided traders in a security, their profit comes from the bid-ask spread. Being the counter-party to almost every trade, they'd make profit from always selling above where they were buying. (Except when the price moved quickly -- the downside to this arrangement.) "The spread goes to the market maker" is just stating that the profit implicit in the spread gets consumed by the market maker.
With the switch to ECNs, the role of the market maker has changed. For example, ForEx trading firms tend to act as market makers to their customers. On ECNs, the invisible, anonymous guy at the other end of most trades is often a market maker, still performing his traditional role. Yet brokers can interact directly with each other now, rather than relying on the market maker's book. With modern online investing and public order books, retail investors might even be trading directly with each other.
Market makers are still out there; in part, they perform a service sold by an Exchange to the companies that choose to be listed on that exchange. That service has changed to helping tamp volatility during normal high-volatility periods (such as at open and close).