Grand Maester is an important position in the government of the Seven Kingdoms. The Grand Maester is the personal maester to the Iron Throne and the Red Keep, and is considered the most senior member of the Order of Maesters. He is a learned man wise in history, science and medicine who also provides counsel. The Grand Maester sits on the King's Small Council, which oversees the day-to-day operations of the realm in the name of the King.
On several occasions in history, a Grand Maester has also been appointed as Hand of the King, serving in both offices at once.
In the A Song of Ice and Fire novels, the Grand Maester is selected by the Conclave. While a Grand Maester can conceivably be removed from the Small Council, either by the King or his Hand, he cannot be stripped of his title as Grand Maester. The order of maesters and position of Grand Maester predate the creation of the Small Council by thousands of years, as the council was only formed after the Targaryen Conquest three centuries ago.
Kings may still try to influence who gets elected as Grand Maester, similar to how strong kings are sometimes able to influence who gets elected as the High Septon of the Faith of the Seven, but even so this is difficult to achieve. Thus while Tyrion Lannister dismissed Pycelle from the Small Council, it wasn't within his power to strip Pycelle of his rank as Grand Maester. At first, after Tyrion's father Tywin Lannister relieved him of his position as acting Hand, he hadn't intended to reinstate Pycelle. Word later reached Tywin, however, that (perhaps in protest) the candidate the Conclave intended to elect as the new Grand Maester was Mace Tyrell's uncle Gormon (youngest brother of his father Luthor). Fearing that this would give House Tyrell more political influence, Tywin simply reinstated Pycelle, as even Lord Tywin did not have the power to influence the election of his preferred candidate.
The chain of office worn by a Grand Maester is a ceremonial symbol of their office, containing numerous links from many fields of study. Because the chain is ceremonial, it does not actually represent the specific areas of knowledge that the current Grand Maester has studied. For example, the Grand Maester's chain contains an iron link representing study of warcraft, even though the current Grand Maester might not have studied warcraft (because he is a peaceful man who rose to prominence as an archmaester of medicine, economics, etc.). In practice, however, the candidate that the Conclave chooses to be the new Grand Maester is usually one of the most senior and leading members of the entire Order of Maesters, and is usually someone who happens to have attained most if not all of the links represented in the ceremonial chain of the Grand Maester.
The position of Grand Maester is usually held by the preeminent member of the entire order of maesters, often a senior member with many decades' worth of accomplishments to his name. As a result, they are often older men and thus don't tend to spend a very long time in office before they reach the end of their lives. It is therefore unusual that Pycelle was selected as Grand Maester at only 42 years old, and has thus had the uncommonly long tenure in office of over forty years (though in the centuries-long history of the maesters, such things are not entirely unheard of). The reason Pycelle was selected at such a young age is because the last three Grand Maesters before him were old men who died in rapid succession: the first two each died under a year after taking the office, and the third died of a chill before he even reached King's Landing. In frustration, it was decided to select a young and healthy man as the new Grand Maester.
In "Fire and Blood", Pycelle says that "In the past 67 years, I have known, truly known, more kings than any man alive" (i.e. Aemon might be older than him, but Pycelle has worked on a daily basis with all kings during this time). Going by the chronology in the books, 67 years ago was during the reign of Maekar I. However, the books also state that Pycelle became Grand Maester during the reign of Maekar I's successor, Aegon V. Either this is a dialogue error (unlikely, as Pycelle says "sixty-seven" quite clearly), or Pycelle may have been loosely referring to his entire time of service as a maester, including the years before he was made Grand Maester. The books do state that Pycelle became a maester during the reign of Maekar I. Even if this is the case, it isn't clear how Pycelle would have known Maekar I before he was Grand Maester; the simplest explanation might just be that Pycelle was speaking loosely.
It is more difficult to parse out when some of the other Grand Maesters lived. In the novels, the last entries in Malleon's book of noble lineages is from ninety years ago (in the TV continuity it extends to the present day, but other maesters may have simply updated it over time). This places Grand Maester Malleon's tenure around ~210 AL. Meanwhile, the last of the four kings that Kaeth wrote about in his book was Daeron II, who died in 209 AL. Both Malleon and Kaeth must therefore have been Grand Maester within a decade or so of each other, with Kaeth apparently following Malleon (based on the assumption that Kaeth wrote about Daeron II after he died, not in the middle of his reign).