Good grief
This is yet another example of a minced or euphemised oath. In this instance, it acts as a substitute for good God and dates from c. 1900. See Cor blimey, Crikey, Gee, Golly, Gosh, Jeez etc.