To a point, the basic contract approved by state and local real estate boards serves everyone well. The problem is that in a standard real estate transaction, the seller's agent presents the contract. It's in the agents and seller's interest to make the sale quickly, not necessarily to look out for the buyer. Usually, should something go wrong before closing despite the buyer's best efforts to obtain financing and complete the sale, the buyer typically gets the deposit money back. But that's not always the case.
Nothing says that the lender has to go through with the loan.
Banks generally can turn down a loan very late in the process if the borrower's financial situation goes in the tank or a family emergency changes things for the worse. In fact, some states are tipping the scales in favor of the seller. Colorado, for example, has changed the standard sales contract such that if a buyer's loan is approved, but later canceled by the lender for some reason prior to closing, the buyer is considered in default. Unless the seller feels charitable toward you, you can kiss your deposit money goodbye. Not only that, the seller has the right to sue you in court.