We painted new drywall before it was primed. Now I am painting a few years later and some of that paint peeled off. How do I fix this?
Paint that has not properly adhered to the surface below could definitely peel off with the slightest touch. Depending on conditions, any masking tape might cause this; however I would suggest using high quality painter's masking tape to minimize the chances.

The soft material you have encountered under the peeling paint is the drywall joint compound used to cover edges, corners, and joints when drywall is installed.

I am afraid that you are in a tough spot now that it has begun to peel. You need to make sure the paint that is most unstable is removed, or it is likely to peel off in the future, including when you repaint the wall. Then you will need to:


sand the areas where sound paint meets substrate until the interface is smooth, then prime and repaint.


OR


use a wide trowel/mud knife to apply one or more coats of drywall finishing mud (sometimes called topping compound) to the peeled area, sanding after each coat, until the wall is smooth and free of visible imperfections. Then prime and repaint.