Honestly, very little. Mainly you sign your life away to the bank that gave you the purchase money. But having a good settlement attorney can certainly make your life--and your home purchase--a lot easier. Here's a good article from the Post.
Buyers have the right to choose the transaction's settlement attorney, who represents neither the purchaser nor the seller. (I know, it's a little weird...the attorney represents the transaction itself.) I know in some states it's common for buyers and/or sellers to hire their own attorneys, but I haven't been to one yet in this area where that's been the case.
A good agent should have relationships with one or more reliable settlement attorneys. And yes, there are often "relationships" between the large brokerages and settlement firms, as noted in this article. I wish I knew more about the fee sharing -- I know I don't see a dime of it, and I'd be crazy to risk a good client relationship over something like that anyway. Who wants to work hard for months on a deal only to risk having it blow up at settlement?? I recommend settlement attorneys based on their thoroughness, reliability, and availability to answer questions along the way, (and of course fees.)
You designate your choice of settlement attorney when you write the offer, though, so it pays to be educated on this topic earlier than later in your home-buying process. And, as always, it helps to be working with an agent you trust who can recommend qualified people for your "team."