Prepubertal girls are more susceptible to vaginal infections due to
- Lack of estrogen - leads to thinning of the vaginal mucosa
- Lack of pubic hair to protect the area
- Lack of labial fat pads
Source: Pediatrics Clerkship, University of Chicago.
Note that, under Etiology, the above source also lists "Foreign bodies".
Sand can be an irritant:
If an irritant is found to be the cause, it’s important to avoid it in the future, whether it’s [...] or sand (from a sandbox or a day at the beach).
Source: A to Z: Vaginitis, Conneticut Children's Medical Center
There does even exist the term sand box vaginitis:
For the child with "sand box" vaginitis caused by sand between the folds of the labia and vagina, snug underwear and cleansing of the vulva will suffice.
Source: Lavery, J. P., Sanfilippo, J. S.: Pediatric and Adolescent Obstetrics and Gynecology, New York, 1985, p. 231
I'm no medical professional but one could conjecture that a bathing suit would better protect a toddler's genitals from irritants like sand. However, regarding the bathing suit:
Good hygiene habits to teach children:
- Change your child's bathing suit as soon as finished swimming
Source: Vulvovaginitis, Cincinnati Children's
The reason:
Don’t sit in wet clothes. Yeast thrives when it’s warm and damp.
Source: Preventing Vaginitis, Saint Luke's
Conclusion:
Sand can be an irritant and "transport" infectious agents. Prepubertal girls are more at risk since their genitals are not so well protected. It makes sense to try to prevent sand from getting there and a bathing suit probably provides protection. However, a wet bathing suit is also a potential risk factor.
You may ask your pediatrician, too. Also check if she got any problems so far. A possible solution might be to make sure she either wears something when playing in sand or sits on a small mat (thanks to @Pam for the suggestion), but perhaps not when she wants to swim.