The English ing-form can take a wide range of grammatical functions. One of those is being a noun, a function the German equivalent does not share. Thus your translation is wrong. How to get it correct?
You need to find out what the German noun would be for "learning German". The simplest way would be
Deutschlernen ist gut für dich.
However, this is not very good style, and there is no real consensus as to how to spell "Deutschlernen". So the phrasing basically doesn't work, and you'd use the first one instead.
A general answer is hard to give as it always comes down to how idiomatic the respective noun would be. However, using the zu-version is a safe bet, since we're talking about an activity and so phrasing it using a verb is more natural.