The way a three electrode potentiostat works is to
- read the potential difference between the Reference electrode and the Working electrode using a very small DC current(generally pA level). (Just like MaxW mentioned)
- Compare this potential to the desired voltage level as input by the user or a function generator.
- Adjust the voltage of the counter electrode until the difference between the desired voltage and the measured voltage is zero.
The main advantage of a three electrode experiment over a two electrode experiment is that the electrochemical voltage that your counter reaction has stays constant. Because you are not passing significant currents through your reference electrode, it's electrochemical potential stays constant. The counter reaction that is happening on the counter electrode may change throughout the experiment without changing the measurement/control of the electrochemical potential of interest.
(In response to a comment)
When a significant current passes through the reference electrode the activity ratio of the reactants and the products are prone to changing. This change in the activity ratio ends up changing the potential based on the Nernst equation:
$E = E^0 + 59.2mV/n * log(ActivityRatio)$
The best way to make a reference electrode is to design the electrode such that the activity ratio stays constant over a long period of time and can resist high current flow. Ag/AgCl is great because of this. Both silver and silver chloride are solids, so as long as there is any Ag and AgCl in the system the potential will stay constant. The electrolyte is kept saturated by keeping solids in the solution and that assures that the electrolyte concentration doesn't change as well.