Το να κοιμάται είναι καλό would mean "It's good that he is sleeping".
You could use other forms of the verb κοιμάμαι (the citation form is usually the first person singular present indicative, i.e. the "I" form not the "he" form) but it would indicate that the action is performed by that person.
Το να κοιμάσαι είναι καλό could also mean specifically "It's good that you sleep" but, as in English, you can also use this generically: "It's good to sleep" (regardless of who does the sleeping -- "you" as in "anyone" rather than "you" as in "the person I am talking to right now".)
This sentence is an example of gerund in English. Most of the sentences in this "Gerund" section are not. Some people confuse gerunds and present participles because the form is identical. https://www.englishgrammar.org/gerund-present-participle/