"Boneyards" is a misnomer. Storage facilities might be a better choice. "Boneyard" suggests that it's a place the aircraft go to die or be stripped for parts; that does happen to aircraft which have reached the end of their economic or legal service life, but most of the facilities you'll see are for long term storage.
Some of the facilities, such as AMARC in Tucson (at Davis-Monthan), where you'll find the military aircraft, is both long term storage and a facility that's used for other purposes, such as obtaining parts. Many aircraft that get placed in storage may be capable, useful aircraft that are simply in transition. Some get used by foreign militaries. Some may be part of a fleet reduction or retirement. AMARC had a lot of B52's that were dismantled or chopped up as part of the SALT (strategic arms limitations treaty) agreements.
Airlines park aircraft when reducing or changing fleets, and sometimes aircraft get parked when they the buyer or leaser can't afford the payments. A few years ago Northwest parked a number of 747-200's when they shelved their cargo program and merged, and Kalitta Air bought the airplanes for parts, and for use in the field. In the meantime, the aircraft were parked in Marana, AZ. It's not uncommon to see fleets parked as they become obsolete; that doesn't mean there's no service life, but it means that the user has changed to something else. Many 747-400's have been parked, for example, as the users moved to 777's. The 747's have a lot of life left, and many get repurposed as Boeing Conversion Freighters or sold to foreign airlines, but for their original duties, they had become economically obsolete as they were replaced.