Mothballs are a registered pesticide and should be used according to the pesticide label instructions. The instructions for mothballs do not allow for outdoor use.
Mothballs tend to have one of two active ingredients: dichlorobenzene or naphthalene. Some products containing naphthalene are registered in some states as an outdoor mammal repellent. Check with your state pesticide agency on what is available.
In any case, naphthalene is only marginally effective when used as a repellent. Wash all vegetables thoroughly before eating (again, follow the label instructions).
A 3-foot-high chicken-wire fence is the most effective way to keep rabbits out of the garden. Dig the bottom 6 inches of the fence into the soil.
Controlling Cottontail Rabbits