Two giants of psak halakha in the 20th century disputed whether we are permitted to use a timer switch on Shabbat. For a full discussion of this topic see Rabbi Michael Broyde’s excellent article here.
However below is a brief description of the dispute and the reasoning behind it. The disagreement is based on a Beraita that says that one is permitted to open his sluice gate, before Shabbat, to allow water to flow into his garden or field on Shabbat. Similarly one is permitted to put wheat into a watermill before Shabbat and have the mill grind the wheat on Shabbat. The Rabbis, however, prohibited letting a mill operate on Shabbat because it makes excessive noise (according to Rabah).
(a) Rav Moshe Feinstein (in Igrot Moshe OC 4:60) rules that one may not set a timer before Shabbat in order to cause a Melachah to be performed on Shabbat. He writes that although the Gemara permits certain actions to be done prior to Shabbat when the results of those actions will occur on Shabbat, that allowance applies only when the process of the Melachah began prior to Shabbat. In the case of Shabbat clocks, however, the Melachah begins on Shabbat!
Rav Moshe Feinsten writes two reasons why the use of a Shabbat clock should be prohibited.
1) the Halachah prohibits one from telling a non-Jew to perform Melachah for him on Shabbat. Just as one may not tell a non-Jew to perform Melachah for him on Shabbat, one may not “tell,” or program, a mechanical device to perform Melachah for him on Shabbat.
2) Rashi (DH she’Yitchanu) explains that one may not have his millstone operate on Shabbat because the noise that it makes is a disgrace to Shabbat, and if people were to have their mills running on Shabbat they would be transgressing the Mitzvah of Kavod Shabbat, honoring the Shabbat. Similarly, setting a Shabbat clock to do Melachah on Shabbat is a disgrace to Shabbat and a violation of the Mitzvah of Kavod Shabbat.
Nevertheless, Rav Moshe Feinstein does permit the use of a Shabbat timer for setting lights to go on and off. Even though he prefers to prohibit the use of a Shabbat timer altogether, he permits using it for lights, because it was the accepted common practice in Europe to have a non-Jew extinguish and re-kindle the lights in the homes of Jews at given hours. We do not have to be more stringent with regard to a Shabbat timer.
(b) Other authorities differ with Rav Moshe Feinstein’s ruling. The Chazon Ish (OC 38:2-3) permits setting a Shabbat timer to cause a Melachah to be performed on Shabbat, and this is the Halachah as recorded in Shmirat Shabbat K’Hilchata.
Rav Shlomo Zalman Aurbach (in Minchat Shlomo #11) even permits changing on Shabbat the time that a Shabbos timer is set to perform a Melachah by altering the controls in such a way that one delays the action that the Shabbat clock is set to cause, because doing so is not considered an act of performing a Melachah.