He had been in poor health for quite some time, and people were declaring him dead when in fact he wasn't.
He went from being a prisoner to president of South Africa in the 1990s:
Mr. Mandela’s quest for freedom took him from the court of tribal royalty to the liberation underground to a prison rock quarry to the presidential suite of Africa’s richest country. And then, when his first term of office was up, unlike so many of the successful revolutionaries he regarded as kindred spirits, he declined a second term and cheerfully handed over power to an elected successor, the country still gnawed by crime, poverty, corruption and disease but a democracy, respected in the world and remarkably at peace.
The question most often asked about Mr. Mandela was how, after whites had systematically humiliated his people, tortured and murdered many of his friends, and cast him into prison for 27 years, he could be so evidently free of spite.
The government he formed when he finally won the chance was an improbable fusion of races and beliefs, including many of his former oppressors. When he became president, he invited one of his white wardens to the inauguration. Mr. Mandela overcame a personal mistrust bordering on loathing to share both power and a Nobel Peace Prize with the white president who preceded him, F. W. de Klerk.
And as president, from 1994 to 1999, he devoted much energy to moderating the bitterness of his black electorate and to reassuring whites against their fears of vengeance.