HOW DID we get in this mess? Almost every day another large bank reports an increase in non-performing loans. Junk bonds are defaulting at a record rate, and scores of leveraged buyouts are in trouble. Commercial real-estate prices are falling in most parts of the country, and vacancy rates are at alarming levels. No one doubts that we are in a serious financial mess.

But we didn't get into all this trouble overnight. How did a man as smart as Michael Milken end up creating so flawed a market -- and why did nearly every leading investment firm jump on his junk bond bandwagon? Where was the wisdom of Wall Street, the fabled savvy of the private sector, the vaunted discipline of the marketplace while all this was going on? The answer is that people run the financial system, and people are greedy. When their self-interest is allowed to run unchecked, especially in a marketplace where almost all the other players are in equally avid pursuit of enormous gain, excess becomes the order of the day and prudence is checked at the door.

During the decade of the 1980s, investors and lenders abandoned historical yardsticks of value. The prevailing attitude in government was that we would grow our way out of our economic problems. The conventional wisdom in corporate and financial sectors was that the occasional bad deal could quickly and effortlessly be restructured. Capital was regarded as available in virtually unlimited supply so, there was no need to have any in hand.

Let's look at some of the highly leveraged deals of the 1980s from the perspectives of the principal parties involved. The lessons we can learn from them apply equally to the real estate and commercial banking problems we currently face.

The Dealmakers: Swinging for the Fences Why did dealmakers make so many bad deals? Today many blame an unforeseen economic downturn. But aren't economic downturns always unforeseen as to timing, and shouldn't deals have been structured to withstand them? Why weren't they?

The biggest reason is that in the 1980s dealmakers had access to enormous amounts of non-recourse debt financing that allowed them to swing for the fences with other people's money. The repayment prospects of a non-recourse loan depend entirely on the soundness of the transaction itself; if the deal fails, there is no recourse to the borrower personally. Such financing was available at relatively low interest rates (extremely low, when the risk is taken into account) and with little or no equity investment required. This promoted dubious transactions, since the downside risk was small and the upside gain was enormous.

Competition to make deals was intense. As a result, the conservative, responsible dealmaker either relaxed his/her standards or sought a new line of work. No one concerned about things like possible recessions was able to consummate any deals -- someone else would have bid higher.

Tales of early successes, such as the widely chronicled and enormously profitable LBO of Gibson Greetings, helped attract new dealmakers and push takeover prices up. After all, the couple of million dollars extra you paid scarcely mattered in the face of enormous profits.

One other powerful stimulant lubricated the wheels of dealmaking: up-front fees. Dealmakers were frequently able to extract fees upon closing a transaction that equaled or exceeded the equity investment -- the money actually invested in the companies involved in the deal. In the buyout of RJR Nabisco, total fees to all parties for a few months' work approximated $1 billion.

Up-front fees, tales of past successes and non-recourse debt financing all caused a feeding frenzy that resulted in entirely new standards of business valuation. Transactions were completed at unprecedented multiples of earnings and cash flow. New valuation tools were invented that conveniently "justified" the foolishly high prices being paid. Analysts valuing companies deliberately ignored not only economic but also physical laws; implicitly they assumed that plant and equipment did not wear out! New debt instruments, such as zero coupon and pay-in-kind junk bonds, which deferred the payment of cash interest for several years, were also introduced. Noneconomic transactions were made to look viable. Investment Bankers: Skimming the Pot The investment bankers, some of whom were also dealmakers in their new capacity as merchant bankers, were rewarded by enormous up-front fees while incurring virtually no risk. As with the other players, there were many reasons to play the game and few to abstain. At the individual level, it was psychologically difficult to watch others make fortunes yet remain on the sidelines. At the firm level, one had to participate in order to be an all-service investment bank. The only real risk was to those who chose not to participate: They would lose out to their competitors for as long as the mania lasted. Bank Lenders: Shifting Risk to Uncle Sam None of these transactions would have been possible, however, without the complicity of lenders, primarily banks and junk bond buyers. Bankers were caught in what investment adviser Marc Perkins has termed "a compulsion to lend." Deregulation had seriously weakened most commercial banks. Large corporations, having by the early 1980s gained direct access to the commercial paper market, no longer needed the banks. And interest rate deregulation meant that the interest rates banks paid to obtain funds exceeded the yield from holding cash, so they desperately needed to make loans.

Bank loans to highly leveraged transactions not only yielded high rates of interest but also provided substantial up-front fees (which borrowers paid with some of the money they borrowed). Earlier losses in loans to farmers, real estate developers and Third World countries had left many banks in a weakened position; up-front fee income was a quick fix to a profits shortfall.

But if the banks were making very risky loans, who was supplying the money? The answer, of course, is that the depositors were. Deposit insurance had been enacted in the 1930s for the purpose of promoting depositor confidence in the banks. Over time, insurance had been extended to cover more accounts, and the maximum amount insured per account was also increased. People also came to rely upon the "too big to fail" doctrine, trusting that the largest banks would be bailed out by the government no matter what. Taken together, these changes had the unintended (albeit widely predicted) side-effect of encouraging reckless lending practices, since depositors were relieved of responsibility for monitoring bank creditworthiness.

Enjoying the best of both worlds in a deregulated environment with government deposit insurance, the bankers started acting like the dealmakers. Anxious to get in the game, almost every large bank in the country competed aggressively on loans for highly leveraged transactions. Only a few praiseworthy institutions, such as Republic New York and First Wachovia, which had built other profitable niches, resisted the hysteria. Junk-Bond Buyers: The Ultimate Patsy Junk-bond investors were the patsies in these deals, earning the least reward for the risk undertaken. Junk bonds were sold on the basis of misleading and deceptive promises, faulty analysis and flawed concepts. In the decade of suspended disbelief, the firms that issued junk bonds were expected to grow so fast that they would be able to pay off their expensive debt. To prove that junk bonds weren't really risky, promoters pointed to the low historical default rates on "fallen angels," high-yield bonds of former investment-grade companies that had fallen on hard times. But fallen angels were a tiny part of what eventually became a $200-billion market of newly issued junk bonds. And the fact that the junk market was growing so rapidly made it impossible to calculate default rates accurately simply because most of the deals hadn't had time to go sour.

As more and more deals were done, the quality of deals inevitably worsened, virtually ensuring investor losses. These pitfalls and many others were obvious at the time, but the financial world deliberately ignored them, choosing instead to retain faith in the magic of junk bonds. Why?

For one thing, numerous academics, including some on the payroll of Wall Street junk bond underwriters, had given junk bonds a stamp of approval. With these assurances, greedy individual investors, known as "yield pigs" among brokers, sought the double-digit yields they had lost when interest rates fell from the high inflation years of the early 1980s.

Prominent mutual-fund organizations rushed to form junk-bond funds, profiting from the management fees on the assets. Their lack of concern about the investment's soundness showed in the fact that few, if any, fund managers invested personally in their own funds. And several were effectively bribed to purchase particular junk bonds for the funds they managed.

Junk-bond mutual funds competed for assets based on the highest reported yield -- usually offered by the riskiest investments. This resulted in a Gresham-like market response, with the bad junk bonds effectively driving out the better ones. The attitude became, why bother to issue creditworthy junk bonds if people will buy bad ones?

Savings-and-loan buyers of junk bonds, many of which had grown rapidly from the infusion of brokered deposits, loved junk because it allowed them to earn high profits while putting up very little of their own money. This in turn allowed them to report big profits -- and justify high management salaries and perquisites and big dividends to owners.

Likewise, insurance companies needed high yielding investment vehicles to maintain profitability. Junk bonds filled the bill. Although insurance companies are not government-insured, they convey an impression of soundness that dissuades most customers from inquiring into their creditworthiness. Consequently, insurance companies were in the position of taking high risks with other people's money. Equity Investors: A New Breed Equity holders typically have the strongest interest in the long-term health of a company because they have a lot at stake and they're the last to be repaid. Equity, such as the common stock in a publicly held company, is the most junior component of a company's capital structure: Equity gets what's left after all the debts are repaid.

But equity investors in the highly-leveraged transactions of the '80s were a different animal. Because of the small initial investment required, and the enormous potential return from a successful deal, equity investors became far more interested in quick gain than in the long-term success of the companies involved. And they were able to get those quick gains, despite overpaying, by reselling some of the assets of the companies to even greater fools. Using other people's money, combined with just a little of their own, they too were able to swing for the fences.

Equity investors, particularly in the early transactions, were the direct beneficiaries of the mispricing of junk bonds. Junk investors bore most of the risk of these transactions, but left substantial potential return on the table for equityholders.

Many of the equity investors were also participants in LBO funds, whose managers had their own set of incentives. Usually, the managers received management and transaction fees and a share in profits. Thus there was a powerful incentive to make deals, and with the heated competition to complete transactions, little opportunity to be selective. Corporate Managers: Conflicting Interests Finally, corporate managements were motivated by personal financial considerations to acquiesce in, or in some cases to initiate, transactions. In many instances, managements were able to sell their personal stockholdings at high prices and either invest in the new entity created by a takeover or buyout at a favorable valuation or receive free warrants or options. Managements thus often acted in conflict with their shareholders' best interest.

Academics justified many of these transactions on the grounds of increased efficiency, arguing that high debt levels were good because they motivated management to work hard. Others praised these transactions for increasing government tax receipts. Such conclusions, needless to say, failed to examine the consequences of excessive debt. The End of the Game By mid-1990, the new-issue junk-bond market was out of business, and banks had greatly tightened their lending criteria. Almost no one could do deals anymore, even at more reasonable prices. Companies dependent on asset sales to repay debt were unable to complete sales at projected prices. Marginal creditors found themselves unable to refinance maturing debt.

By now, it has become clear that the banking system is in a Catch-22. If bank credit continues to be unavailable to finance asset sales (and real estate transactions) at reasonable prices, asset values will continue to decline. This, in turn, will cause more and more bank loans to sour. Yet losses on existing loans have shrunk capital at many banks, causing them to cut back on new loans, even to sound borrowers. The credit expansion of the 1980s is most definitely in reverse gear.

In retrospect, we can see how virtually every part of the financial establishment was motivated by self-interest and often greed to engage in financial recklessness. We cannot outlaw greed, nor should we try, but we must incorporate its motivational force into whatever system we adopt.

Institutional structures like deposit insurance, vehicles like mutual funds and policy changes such as deregulation must be analyzed by policymakers not only for their numerous benefits but also for their adverse consequences. Human nature being what it is, small loopholes are likely to be exploited until they become big ones, and big ones until they turn into financial disasters.

Reducing the ceiling on deposit insurance and limiting the number of insured accounts per person are obvious first steps. Ultimately, we must either adopt risk-based deposit-insurance premiums or consider privatization of deposit insurance to hold bankers more directly accountable for the risks they incur.

A number of rule changes may also help. If corporate proxy rules were changed from the current ones that cause shareholder voting to resemble old-style communist elections, we wouldn't be dependent on corporate raiders to unseat incompetent or entrenched managements. And if institutional investors were compelled, either by law or better yet by their clients, to invest substantial personal funds in whatever securities they bought for client accounts, the quality of their portfolios would quickly become more prudent.

Unfortunately, the dialogue today centers on how to clean up the current mess, not on how to prevent the next one. Who knows whether we have the political will to focus on the fundamental causes of today's problems? Such work will be difficult; changes will require behavioral adjustments by many, and any change is likely to have complex consequences. But if we choose to pursue only stopgap solutions, we shall have none at all.

Seth Klarman is president of The Baupost Group, Inc., an investment management firm in Cambridge, Mass.