게 and 기 are different verb ending forms(conjugations), and 게 can also be a contraction of 것이.
1. -기 creates a noun form from a verb, much like the gerund in English. "-ㄴ/ㄹ/는 것" is another way.
- 음악을 듣는다 (sentence) -> 음악(을) 듣기(listening to music - noun phrase).
- 책 읽기(reading), 스키 타기(skiing), 수영하기(swimming).
This noun form also makes idiomatic phrases, like -기 싫다, -기 쉽다/어렵다, and many others.
- 나는 일찍 일어나기 싫다 = I don't want to get up early.
- 그 학교 입학시험에 합격하기(는) 어렵다 = It's difficult to pass the entrance exam for that school.
- 그렇게 하기는/하기에는 너무 늦었다 = It's too late to do that now. (는 adds added focus and rhythm)
2. -게 makes a verb form expressing an intention or purpose, like "so as to..." or "so that ..." (similar to -도록).
- 아이가 놀게/놀도록 장난감을 만들었다 = Made a toy for the child to play with.
- 아이가 놀 수 있게/놀 수 있도록 장난감을 만들었다 = Made a toy so the child can play with it.
3. 게 as a contraction of 것이 creates noun phrase (typically the subject of a sentence) following verb forms -ㄴ, -던 (past), -는(present), or -ㄹ(future).
- 이제 그만 가는 게 좋겠어요 = Leaving now seems like a good idea => It looks we should get going now.
- 아는 게 힘이다 = 아는 것이 힘이다 = What you know is power => Knowledge is power.
- 아는 건 힘이다 = 아는 것은 힘이다 = similar, but using 것은 = 건, for a different nuance.
Don't mix up the (2) and (3) usage of 게. (2) forms an ending of a verb while (3) acts as a part of subject phrase.
e.g. 아이가 자게 놔 둬 [자도록 놓아 둬] = Let the baby sleep. 게-2.
e.g. 아이가 자는 게 보기 좋다 [자는 것이 보기(에) 좋다] = It's nice to see the baby sleep. 게-3 (자는 게) and 기-1 (보기).
e.g. 아이가 자는 건 보기 좋다 [자는 것은 보기(에) 좋다] = The sight of a sleeping baby is nice. (different nuance because of 것은).