perhaps abstracted from Old English swa same "the same as," but more likely from Old Norse same, samr "same," both from Proto-Germanic *samon (cf. Old Saxon, Old High German, Gothic sama, Old High German samant, German samt "together, with," Gothic samana "together," Dutch zamelen "to collect," German zusammen "together"), from PIE *samos "same," from root *sem- "one, together" (cf. Sanskrit samah "even, level, similar, identical;" Avestan hama "similar, the same;" Greek hama "together with, at the same time," homos "one and the same," homios "like, resembling," homalos "even;" Latin similis "like;" Old Irish samail "likeness;" Old Church Slavonic samu "himself").
Old English had lost the pure form of the word; the modern word replaced synonymous ilk. Colloquial phrase same here as an exclamation of agreement is from 1895. Same difference curious way to say "equal," is attested from 1945.