CDG and Versailles are on opposite sides of Paris. Traffic will affect you no matter what route you take. The shortest route would be A1 (from CDG), the périphérique (around Paris to the west), A13 and with minimal traffic it can be done in about 1 hour. An alternate route would be A1 to A86 to A13, taking about the same amount of time. Another longer option would be A1 to A3 to A13.
The big unknown will be the traffic and at what time you depart the airport. If it is raining or a particularly busy morning, the en route times can easily double (or more than double). Car rental desks have boards showing the local traffic and anticipated delays on routes all around the Ile de France. You really would not know the best route option until seeing this real time information.
As has been pointed out, there is no direct train from CDG to Versailles. You could take the RER B to St Michel, change to the RER C for Versailles but work along this route, near Pont de l´Alma, is in progress until August 2019. The en route time will be about 2 hours when this option is available.
There are other rail alternatives but routes will take longer than 2 hours and require several train/bus changes.