How do ground up onions and garlic help an eye infection?

Peel garlic clove and make a cut on it in order to let its juice come out. Now, rub it on the upper eyelid of the infected eye. You might feel a stinging sensation, but it will go after some time. Garlic is an excellent antibiotic and works well to kill infections.