QUESTION: The Beraisa states that an Eved and a Ger are obligated to refrain from Melachah on Shabbos. The Gemara explains that the "Ger" to which the Beraisa refers is a "Ger Toshav," a Nochri who lives in Eretz Yisrael who has accepted upon himself the Seven Mitzvos of Bnei Noach.
Why does the Beraisa say that a Ger Toshav is obligated to observe Shabbos? A Ger Toshav is a Nochri, not a Jew, and the Gemara in Sanhedrin (58b) clearly states that a Nochri who refrains from Melachah on Shabbos is Chayav Misah. (TOSFOS DH Zeh)
(a) RASHI explains that a Nochri who accepts upon himself to observe the Seven Mitzvos of Bnei Noach and not to worship Avodah Zarah is required to observe Shabbos, because desecration of Shabbos is compared to Avodah Zarah (Eruvin 69b). The Acharonim explain that according to Rashi, the Gemara in Sanhedrin refers only to a Nochri who worships Avodah Zarah. Such a Nochri indeed is Chayav Misah if he refrains from Melachah on Shabbos. However, once he accepts upon himself not to worship Avodah Zarah he must observe Shabbos. (ARUCH LA'NER)
(b) TOSFOS (DH Zeh) explains that a Ger Toshav has no obligation to observe Shabbos. Rather, the Beraisa means that a Ger Toshav is similar to an Eved in that a Jew is not permitted to have his Eved, or a Ger Toshav, do Melachah for him on Shabbos. (Rashi himself says this with regard to an Eved, in DH Bein ha'Shemashos.)
Why does Rashi not give the explanation that Tosfos gives? Apparently, Rashi maintains that a Ger Toshav is normally not subject to the will of another person, and thus the verse cannot mean that a Jew is not allowed to tell him to do Melachah; the Ger Toshav has no imperative to listen to what the Jew tells him. If he decides to do the Melachah on his own, the Jew may benefit from it (mid'Oraisa) since there is no Isur d'Oraisa that prohibits a Nochri from doing Melachah for a Jew. Accordingly, the Torah does not mean that the Jew is forbidden to ask the Ger Toshav to do Melachah, but rather the Torah commands the Ger Toshav himself to refrain from Melachah.
(c) The TOSFOS YESHANIM explains that the Ger Toshav to which the Beraisa refers is actually a Ger Tzedek who is in the process of converting. If Shabbos arrives before he completes his conversion (similar to Rebbi Akiva's case of an Eved, as discussed earlier), he must observe that Shabbos. Since he has intention to convert, he is not considered a Nochri anymore with regard to the prohibition against observing Shabbos, and thus he must refrain from Melachah on Shabbos. (See Insights to Kerisus 9:1.)