On 11 February 1990, Nelson Mandela is released from Victor Verster Prison after having spent 27 years in jail. Four years later, Mandela is elected the first black President of South Africa. His presidency faces enormous challenges in the post-Apartheid era, including rampant poverty and crime, and Mandela is particularly concerned about racial divisions between black and white South Africans, which could lead to violence. The ill will which both groups hold towards each other is seen even in his own security detail where relations between the established white officers, who had guarded Mandela's predecessors, and the black ANC additions to the security detail, are frosty and marked by mutual distrust.
While attending a game between the Springboks, the country's rugby union team, and England, Mandela recognises that the blacks in the stadium are cheering for England, as the mostly-white Springboks represent prejudice and apartheid in their minds; he remarks that he did the same while imprisoned on Robben Island. Knowing that South Africa is set to host the 1995 Rugby World Cup in one year's time, Mandela persuades a meeting of the newly black-dominated South African Sports Committee to support the Springboks. He then meets with the captain of the Springboks rugby team, François Pienaar, and implies that a Springboks victory in the World Cup will unite and inspire the nation. Mandela also shares with François a British poem, "Invictus", that had inspired him during his time in prison.
François and his teammates train. Many South Africans, both black and white, doubt that rugby will unite a nation torn apart by nearly 50 years of racial tensions, as for many blacks, especially the radicals, the Springboks symbolise white supremacy. Both Mandela and Pienaar, however, stand firmly behind their theory that the game can successfully unite the South African country.
Things begin to change as the players interact with the fans and begin a friendship with them. During the opening games, support for the Springboks begins to grow among the black population. By the second game, the whole country comes together to support the Springboks and Mandela's efforts. Mandela's security team also grows closer as the various officers come to respect their comrades' professionalism and dedication.
As Mandela watches, the Springboks defeat one of their archrivals - Australia, the defending champions and known as the Wallabies - in their opening match. They then continue to defy all expectations and, as Mandela conducts trade negotiations with Japan, defeat France in heavy rain in Durban to advance to the final against their other arch-rival: New Zealand, known as the All Blacks. New Zealand and South Africa were universally regarded as the two greatest rugby nations, with the Springboks being the only side to have a winning record against the All Blacks up to this point. The first Test series between the two countries in 1921 was the beginning of an intense rivalry, with emotions running high whenever the two nations met on the rugby field.
Before the game, the Springbok team visits Robben Island, where Mandela spent the first 18 of his 27 years in jail. There Pienaar is inspired by Mandela's will and his idea of self-mastery in Invictus. François mentions his amazement that Mandela "could spend thirty years in a tiny cell, and come out ready to forgive the people who put [him] there".
Supported by a large home crowd of all races at Ellis Park Stadium in Johannesburg, Pienaar motivates his teammates for the final. Mandela's security detail receives a scare when, just before the match, a South African Airways Boeing 747 jetliner flies in low over the stadium. It is not an assassination attempt though, but a demonstration of patriotism, with the message "Good Luck, Bokke" — the Springboks' Afrikaans nickname — painted on the undersides of the plane's wings. Mandela also famously arrives onto the field before the match wearing a Springbok cap and a long-sleeved replica of Pienaar's #6 shirt.
The Springboks complete their run by beating the All Blacks 15-12 in extra time thanks to a drop goal from fly-half Joel Stransky. Mandela and Pienaar meet on the field together to celebrate the improbable and unexpected victory, and Mandela hands Pienaar the William Webb Ellis Cup, signaling that the Springboks are indeed rugby union's world champions. Mandela's car then drives away in the traffic-jammed streets leaving the stadium. As Mandela watches the South Africans celebrating together from the car, his voice is heard reciting Invictus again.

Question: Why did Mandella spend 18 years at Robben Island?
Answer: Mandela was in prison at Robben Island for 18 years.