I want to visit some ancient palaces in Frankfurt or the neibouring areas but I do not know which ones are the best
Frankfurt was a Free Imperial City, thus no residence city with a ruler who had his palace there.
Some nobel families built a kind of branch or city palace there.
E.g. Thurn and Taxis Palace
But there is nothing ancient in Frankfurt. Basically everything listed on the above linked site was completely destroyed in WWII.
One of the best is definitly the Residence in Würzburg
Nearer Frankfurt in Hanau is Schloss Philipsruh and Gelnhausen (between Hanau and Fulda has remains of medieval Kaiserpfalz (imperial palace). Ancient but not much tosee but town itself is beautiful with medieval walls, two churches, town gates etc. Look at: http://en.wikipedia.org/wiki/Main-Kinzig
In Buedingen the noble Ysenburg family still live in the castle in the town and nearby is the Ronneburg castle.