It helps build up the immune system (and keep away parasites). There are fishkeepers who give it to their fish once a week.
You can use it to soak some foods in, such as freezedried bloodworms or frozen food or even their veggies, and/or you can put a couple of drops of garlic juice directly to the tank water.
I use minced garlic (in the jars with the spices at the grocery store), but you can use fresh. My jar doesn't have juice, just the little chunks. I just take some of the chunks, put them into a (unused) cup from a Nyquil bottle, put in a bit of tankwater, and some freeze dried bloodworms. I let the whole mess soak for a few minutes, and dump in the liquid and the worms. They love the treat, and it's super healthy for them. I have tried to let them eat the garlic pieces, but they ignore those.
If you regularly feed freeze-dried foods(worms, daphnia, etc.), by the way, you always want to presoak in garlic juice or tankwater. The foods expand when they are hydrated, and you don't want that expansion happening inside the fish's stomach - it can cause bloating and constipation.
You can also use a product called Garlic Guard, but this way is cheaper.