Depending on the make and model, digital pianos can last from several years to decades. High-end keyboards from brands such as Roland give the impression that they last forever. These musical instruments require little maintenance and can last for many years.
However, some models can experience malfunctions that can be either caused by hardware failure or by a software glitch. Many of these can usually be repaired unless the model is too old and there are no more available replacement parts. With a quality piano and proper usage, you should get plenty of years of playing on a digital piano.