Solution 1:

A general guideline is that "g" is sometimes soft before "i", "e" and "y". It is invariably hard for all the other vowels, i.e. "a", "o" and "u".

Given the inconsistency of English spelling, one can never formulate a cast-iron rule.

My guess is that words derived from Latin or French, soften the "g" before "i" and "e" and that words that come from German don't.

I will be very surprised if someone has a complete rule for this. Let's wait and see.