This is a relatively facile analysis coming from a noob, but here is how I understand credit rating agencies.
As I understand it, agencies like Moody's supply solicited and unsolicited credit ratings to firms, with the latter method supposedly forcing companies to register with the agency or risk a credit downgrade. While this method provides banks with an incentive to pay for rating services, it doesn't bind them to a specific ratings agency. Thus, ratings agencies compete for business by offering more favorable ratings of a given target bank's securities. Since banks seem to heavily rely on ratings agencies to evaluate credit, there is a stark information asymmetry in favor of rating agencies and consequently a big incentive for agencies to provide inaccurate information in order to attract business. In addition, there is an incentive for banks to collude with ratings agencies to mark up their low-quality debt in order to artificially boost its value on the market. In practice, this translated into AAA-rated subprime security packages before the subprime crisis.
Ordinarily one would think that an agency would be liable for breach of contract, fraud, or some negligent tort for providing such blatantly inaccurate information. However, the credit ratings agencies have been immunized from suit by successfully claiming that their ratings are public opinion under the 1st Amendment. Is this a failure of the Market, or another example of government-protected fraud?