To write his books Chanakya needed some relief from work. The Emperor would not spare him from prime ministership.
Chanakya also realised that the Emperor needed his protection because Amatya Rakshasa was still there creating trouble. He was a loyal soldier of Nandas and would not accept defeat easily. He was still managing to raised soldiers and sending assassination groups to eliminate Chandragupta. It was only the vigil of Chanakya that assassination bids were failing.
Then, through spies Chanakya learnt that the wife and the children of Amatya Rakshasa were living in the care of Chandanadasa, one of his friends. That was the chance Chanakya was looking for. He got Chandanadasa arrested and announced death sentence for him for sheltering the enemy. It was the ruse of Chanakya to bring Rakshasa out in open.
He knew that Rakshasa was a very principled man who won’t let his fried die for him. His guess was true. Amatya would do anything to save his loyal friend. So, he surrendered to the soldiers of Chanakya and demanded the release of his friend. He thought that he would be senetenced to death anyway.
But Chanakya had other ideas. When Rakshasa was brought to him, he asked if Rakshasa wanted his friend freed and his family spared. Rakshasa replied in affirmative and said he was ready to die for them.
To his utter surprise Chanakya demanded a different price. He asked Rakshasa to become the Prime Minister of Emperor Chandragupta Maurya. Infact Chanakya highly valued the wisdom, administrative capability and the spirit of loyalty of Rakashas. He knew once Rakshasa took up the responsibility he would even die for Chandragupta. Such was his loyalty and dedication.
When Rakshasa became the Prime Minister of Maurya Empire, Chanakya agreed to serve only as subordinate minister.
Now Chanakya had all the time to write down his theories in proper book form. That is how he was able to write his Arthshastra and Neeti books.