Allo nemo,

The word merci has two meanings in French
a) merci / thank-you
b) merci / mercy – (both derived from the Latin merces, mercedis), which has a several meanings we are all aware of: compassion shown, granting of grace, clemency or leniency…

My French dictionaries do not say, but it is not a stretch to believe that the "thank-you" merci evolved from the "granting of a grace" merci.