Paint can be moodier than a teenager. It's great when everything is going right but one little mistake and everything can go south. Paint will peel because of moisture, temperature, sunlight, poor preparation or just bad karma. The karma thing is too involved for this column but the preparation part we can touch on. Dust can ruin an otherwise well executed paint job.
Specifically, the dust that comes from sanding joint compound. Latex paint, even latex primers just can't stick to the stuff. It's like painting the sand at the beach. Latex paint dries so quickly that it stays on top of the dust and so never has a solid foundation to adhere to. If you have ever painted a wall and had the wall bubble in different spots every time you roll it out you were probably doing battle with dust. You can see the powdery film on the back of the peeled paint. The moisture from the paint itself pulls old layers away from the wall.
First and formost is prevention. Wipe down sanded sheetrock or repaired plaster with a damp sponge before painting. If, however the problem is several layers down into the archeology of the walls of your house then go over them with oil based primer. This will seal moisture away from the dusty stratum in question and allow you to patch and paint. I knew a homeowner who lovingly skim coated several entire rooms and then painted right over the dust. Bad idea. Oil based primers are more forgiving on this point as they penetrate deeply and take forever to dry.