What is the relationship between the letters samekh and sin? Did they ever have distinct sounds? Why do they exist as separate letters?
The idea here is that in modern usage they are both actually interchangeable with samech.
For an illustration of this interchangeability see the 15th line of the alphabetical acrostic א-ל אדון, in which a sin appears where we would expect a samech, or the common root א.ר.ס used by חז"ל in place of the Torah's synonymous root א.ר.ש.
The difference in sound between the samech, a voiceless alveolar fricative ([s]) and sin, a putative voiceless lateral fricative ([ɬ]), is hypothesized to have been lost as early as Biblical Hebrew, with its remnants still evident in transliterations like "Chaldean" for "כשדי" and "balsam" for "בושם". In each case, the sin that we would conventionally pronounce as [s] was ostensibly closer to [ɬ], which is, in a way, halfway between /s/ and /l/.
There is a complicated diachronic explanation of exactly how and why this shift took place, which is summarized very briefly on page 73 of this paper, by Biblical Hebraicist Gary Rendsburg.
Not really an answer, but there is a story about someone who came to the Satmar Rebbe (R' Yoel Teitelbaum zt"l) and challenged the Ashkenazi pronunciation which does not differentiate between samach, sin, and tav-rafeh (ת). He shot back with the verse: וכסילים מתי תשכילו! (Read that with heavy chassidishe accent for best effect.)