Serving Hashem Shelo L’Shma Has Value
The Baal Shem Tov zy"a says that this pasuk contains a source of encouragement for the time of the "ikvesa d'meshicha", the generation immediately prior to Moshiach's arrival, when it is very difficult to draw close to Hashem, do teshuva, and properly observe the Torah and mitzvos. During this generation, even serving Hashem in a less than perfect way is beloved by Hashem. If someone serves Hashem and does teshuva fully l'sheim shomayim, it is certainly wonderful. But even if one's avodah and teshuva is only 50% l'sheim shomayim - for example, if one also has in mind that he will receive honor and glory if he learns Torah as long as one has partial thoughts l'sheim shomayim, his avodah will be accepted by Hashem.
This is hinted to in the words of this pasuk: “Im yihiye nidachecha" (if your exiles will be). The word "nidach" can be translated to mean a far-flung person whose teshuva is not 100% sincere. Regarding such a person, it states that he is "at the end of heaven", meaning that he only manages to be partially l'sheim shomayim. Still and all, Hashem says that He will "gather him from there" and accept his teshuva as if it were fully l'shmah.