What is the origin of the different pronunciations of C and G before different vowels?
The vowels represented in most European lanaguages (but not English) by /a/, /o/, and /u/ are back vowels: in pronouncing them the tongue is positioned back toward the throat. The vowels represented by /e/ and /i/ are front vowels: the tongue is positioned toward the front of the mouth.
The /k/ sound represented by Latin /c/ is articulated with the tongue at the back of the mouth. When the syllable /ka/ or /ko/ or /ku/ is uttered, the tongue doesn't have to move very far, if it all. But with the syllable /ke/ or /ki/, the tongue must shift rapidly toward the front of the mouth. The same is true with the voiced consonant /g/.
Consequently, there is a physiological tendency to alter the pronunciation of /k/,/g/ before /e/,/i/—to position the tongue further forward for the consonants in anticipation of the following vowel.
At some point during the Late Roman Empire this colloquial palatalization (reinforced by similar movements of other consonants) became the “accepted” pronunciation. /k/,/g/ before /e/,/i/ became /tʃ/,/dʒ/, evident in modern Ecclesiastical Latin. The pronunciation changed, but not the spelling: for to change the spelling would cut writers and readers off from their literary heritage.
These pronunciations were inherited (and developed further) by Latin's heirs, the Romance languages. And in due course they passed to English. When English literature revived a century or so after the Conquest, its writers were employing a language greatly enriched by French lexicon and were addressing an audience for whom the “literary” languages were French and Latin. These writers naturally adopted French orthography, and its distinct front and back pronunciations for /c/ and /g/.
Well I shouldn't think it comes directly from Latin, as in classical Latin the letter 'c' was only ever used to represent 'k', and never 's'. But I would suspect that the differentiation in English was adopted from the later Romance languages. For example, our pronunciation of 'Caesar' is adopted from Romance 'Cesar' (say zar) or 'Cesare', whereas our spelling is unchanged from the Latin, whose closest modern approximate in pronunciation is probably the German 'Kaiser'.