This question actually has two parts: why do cats like to sleep on clean clothes, and why do they like to sleep on dirty clothes?
To the first one, I would answer: because a pile of laundry (whether folded or just dumped) resembles a nest that cats might use in the wild. It’s comfy, and if you’ve just taken it out of the dryer, it’s warm too! And some would speculate that because clean laundry has no scent, your cat is trying to give it a scent.
Now, the part about dirty laundry is a little different. The nesting factor is definitely there, especially since dirty laundry is not usually folded. In addition, dirty laundry has a “scent” (which we would not consider a good scent, but cats and dogs have different standards for smells than we do); perhaps they like the scent because it reminds them of you. In the wild, a “cat nest” would have a smell that we wouldn’t consider good either. But it’s a familiar, comforting smell to a cat.