I heard this from someone who is heavily involved in airplane scrapping. Most of the time, the livery is painted over because either
The airplane was sold to a scrapping company situated at one of the many boneyards
Some airlines just despise seeing their livery still on an airplane in a boneyard where the state of the airplane isn't cared for giving the airline a bad image
Many examples are Qantas 747-400. The jets that went to Victorville airport went with the livery removed because a company called Jet Midwest had bought the planes. Same situation with the ex-Qantas 744 going to Rolls Royce, the Qantas 744 that went to Tupelo, and the many Qantas at Mojave. Same with KLM. These airlines previously owned their own airplanes and have now sold them off.
Many times BA 747-400 are scrapped with the livery still applied. BA own their airplane and most times see through the entire scrapping of their retired jets like at Victorville, (1-2 at Teruel, Kemble, Cardiff etc) BA's reasoning of not removing liveries sometimes are unknown but I personally believe its cost saving measures. Its challenging to get photos of some planes at Victorville hence many were sent with the livery, but most planes are spray painted Black when they arrive at boneyards like Teruel and Kemble to sort of "Mask" the airlines identity. St Athans is another boneyard, sorta challenging to get photos so many BA went there and scrapped with their full livery.
The logistics are all over the place when it comes to removing the liveries, but simply most of the time a livery is painted over by the airline, or boneyard is simply because the airplane was sold to scrappers, or airlines request the boneyard to mask their planes with the black spray paint.
The only scummy airline I heard of is Lufthansa. They've retired some jets to Mojave with the livery and whenever people take photos, they will attempt to go after them for some meaningless "Damages" caused. Some airlines sell their planes with liveries still attached because some simply don't care or don't have the time. United and Lufthansa are some prime examples.