Mothballs release a strong odor that is indeed repellent to mice and other rodents. However, as the primary use of mothballs is to kill moth larvae, certain precautions must be taken when using mothballs to combat rodents.
Mothballs consist of either naphthalene or paradichlorobenzene; these chemicals evaporate directly from a solid to a sweet gas that is poisonous to moth larvae. While the resultant smell is also repellent to rodents, snakes and other undesired small animals, the use of mothballs for this purpose creates the risk of their being discovered instead by desired animals, particularly house pets, as well as children. Either mothball substance can be highly toxic if swallowed, so reasonable precautions should be taken to ensure safe use if deployed as a rodent repellent throughout a home.