The CDO takes a pool of risky mortgage loans and divides it into slices. For simplicity's sake, let's say that a mortgage-backed security gets divided into two slices when it is transformed into a CDO -- a senior slice and a junior slice. Let's say that the senior slice gets rated AAA+ and the junior slice gets rated BBB-. But if anything goes wrong -- if the homeowners whose loans are part of this security start missing their payments -- the investors in the junior slice have to lose all of their money before the investors in the senior slice start feeling any pain. That's the beauty of the scheme. You take a bunch of bad loans and turn some of them into high-rated gold and some into lower-rated bronze. You sell the gold to the cautious and the bronze to the bold. If a few loans go kaput, the bronze investors suffer. If all the loans go kaput, everybody gets hurt. Unless there's a total financial meltdown, everyone is happily making money.
Kind of reminds me of the bulkheads on the Titanic. "If we start to take on water, close the bulkheads and sail the first class passengers the rest of the way with a hull full of pickled Irishmen!" (chomps cigar)