I was reading this question and wondered why there were so many that were inactive. Considering the cost to build/launch/ship them, and that they are mostly powered by solar energy, why would they go inactive after a relatively short time?
Vehicles in space need propellant for attitude maintenance. The vehicle is essentially dead when the propellant runs out. Propellant depletion is the end goal of a good spacecraft designer. All of the other reasons that follow represent situations that preferably should not happen. But they do happen, at least to some space vehicles.
Vehicles in space need functional avionics systems to gather data and to communicate with the Earth. The vehicle is essentially dead when its avionics have been fried by one too many cosmic rays.
Vehicles in space need electrical power. The vehicle is essentially dead when its solar arrays have degraded to such an extent that the vehicle can no longer serve its secondary (let alone primary) mission.
Nothing in space lives forever. Designing a space vehicle to live forever would be extreme overkill. Space vehicles are instead designed to live for a minimum period of time, but also are designed to not live after some extended period of time.