I can't imagine Tywin allowing his son Jaime to join the Kingsguard. Wouldn't he insist that Jaime stay at Casterly Rock, marry, have children, and carry on the family name? He certainly did not want Tyrion to become lord of Casterly Rock.
In The World of Ice and Fire: The Untold History of Westeros, it is noted that King Aerys and Tywin were close friends as boys, along with Steffon Baratheon. Being such good friends and a close confidant of Aerys, Tywin became the youngest Hand in the Seven Kingdoms at the age of 20. Through the years, as we are well aware, Aerys became paranoid and delusional, believing that his own son Rhaegar and close friends, most notably Tywin, were plotting against him. There are several reasons why Aerys believed this.
His wife Rhaella, although giving him an heir in Rhaegar, had countless miscarriages and still births, until the later births of Viserys and Daenerys, while Tywin's wife Joanna bore him two healthy twins, Jaime and Cersei.
After being kidnapped and held captive at Duskendale by Lord Denys Darlyn, who wanted more autonomy, Aerys believed that Tywin and Rhaegar had deliberately held back in freeing him, hoping he would be killed so Rhaegar could ascend the Iron Throne.
Aerys was inherently jealous of Tywin. He hated how Tywin seemingly had everything that he didn't and at every opportunity sought to undermine and belittle him.
The greatest insult to Tywin came in 281 AC when Aerys appointed Jaime to the Kingsguard. As stated in The World of Ice and Fire: The Untold History of Westeros, p121
Ser Jaime was also Lord Tywin's heir, however, and carried all his hopes for the perpetuation of House Lannister, as his lordship's other son was a the malformed dwarf, Tyrion. Moreover, the Hand had been in the midst of negotiating an advantageous marriage pact for Ser Jaime when the King informed him of his choice. At a stroke, King Aerys had deprived Lord Tywin of his chosen heir and made him look foolish and false.
Tywin couldn't refuse his king appointing Jaime, as this insult possibly would have cost not only him his life but caused the complete downfall of House Lannister, which is what happened to House Darklyn. All Tywin could do was resign from his post as Hand and retire to Casterly Rock, which Aerys allowed him to do.
Yes, Tywin would insist on having Jaime be his heir. But Tywin wasn't in command of the kingdom, the Mad King Aerys Targaryen was. King Aerys did this precisely to spite Tywin, of whom he was jealous/distrustful.
Note that while this wasn't what Lord Tywin wanted, it wasn't necessarily the worst outcome for Jaime, since getting married didn't interest him. Remember he was secretly in love with his sister Cersei.
In "A storm of swords" there is also a narrative by Jaime himself concerning his appointment to the Kingsguard. On a visit to King's Landing Cersei takes him aside and tells him that Tywin plans to marry him to Lysa Tully. Cersei then goes on and says he should take the White:
"Father will never consent," Jaime objected.
"The king won't ask him. And once it's done, Father can't object, not openly. Aerys had Ser Ilyn Payne's tongue torn out just for boasting that it was the Hand who truly ruled the Seven Kingdoms. The caption of the Hand's guard and yet Father dared not try and stop it! He won't stop this, either."
"But," Jaime said, "there's Casterly Rock..."
"Is it a rock you want? Or me?"
George R. R. Martin. A Storm of Swords. p. 156.
This shows that the idea of Jaime being part of the Kingsguard first came from Cersei, although I agree that all the information posted in the other answers led to why Aerys chose him.
Anyway, I know the question is already answered, but I still wanted to give some extra info (even though it is essentially the same only through a different point of view).
Perhaps , in part for the same reason that the Medicis & other prominent families allowed their heirs to join the Church & similar feudal institutions.
They would gain access to gossip and a networks at court and with it significant influence.
They never expected these people to actually take their vows seriously, and as such never expected these positions to be permanent. Then as now, and in Westeros, failure to play the game and stand on principals usually resulted in a dagger to the back.