All of these cases are obviously making a comparison to something previously mentioned, which isn't disclosed in the question. I'll describe some situations in which your sentences would be what I would expect to see.
- Using a keyboard is better.
Person 1: "My tablet has a simulated on-screen keyboard, but I find it hard to type because there is no tactile feedback."
Person 2: "Using a keyboard is better."
The keyboard is the subject of the sentence and you're comparing it to the previously mentioned alternative.
- To use a keyboard is better.
This is an awkward construction that I wouldn't expect to see in normal speech. Starting a sentence with "To use a keyboard...", I would expect it to be an instruction: "To use a keyboard, plug the connector into the back of your computer."
This would not seem to be part of a direct comparison to something mentioned just prior, so the "is better" seems like a non sequitur.
- It's better to use a keyboard.
Person 1: "I need to input a lot of text into my computer. I'm thinking of using a microphone and voice-to-text software to do it."
Person 2: "It's better to use a keyboard."
The difference I see between 1 and 3 is a nuance based on use of the infinitive and the subject of the sentence.
"To use a keyboard" refers to it in the abstract, more as a method than a direct action. That is coupled with the subject of the sentence. "It" refers to the task. So sentence 3 describes an alternate way to accomplish the task more than comparing the keyboard to something else.
- It's better using a keyboard.
This is the "optometrist" example, "Is it better this way or that way?"
Person 1: "Do you prefer using the on-screen simulation or an actual keyboard?"
Person 2: "It's better using a keyboard."
This construction reminds me of a 1960s Coca Cola slogan: "Things go better with Coke!" Sentences 1 and 3 focus on the keyboard or the task for which the keyboard is a critical element. Sentence 4 seems to focus more on comparing the experience of performing the task in different ways, with the keyboard as a variable.
Comparing sentences 1 and 4: sentence 1 starts with "Using a keyboard", making the keyboard the subject of the sentence. Sentence 4 starts with "it", making the process or the comparison the subject of the sentence.
Comparing sentences 3 and 4: "using a keyboard" describes the action of using it. "To use a keyboard" refers to it more abstractly as a method. So the difference is somewhat like using either "if" or "when":
It's better (the task can be accomplished more effectively) if you use a keyboard
It (the experience) is better when using a keyboard.