We use color-magnitude diagram synthesis together with theoretical relations from non-linear pulsation models to approach the long-standing problem of the Oosterhoff dichotomy related to the distribution of the mean periods of fundamental RR Lyrae variables in globular clusters. By adopting the chemical composition determined from spectroscopic observations and a criterion to account for the hysteresis mechanism, we tuned age and mass-loss to simultaneously reproduce the morphology of both the turn-off and the Horizontal Branch of a sample of 17 globular clusters of the Milky Way and of nearby dwarf galaxies in the crucial metallicity range (-1.9<[Fe/H]<-1.4) where the Oostheroff transition is apparent. We find that the Oosterhoff dichotomy among Galactic globular clusters is naturally reproduced by models. The analysis of the relative impact of the various involved parameters indicates that the main responsibles of the dichotomy are the peculiar distribution of clusters in the age-metallicity plane and the hysteresis. In particular, there is a clear connection between the two main branches of the age-metallicity relation for Galactic globular clusters and the Oosterhoff groups. The properties of clusters' RR Lyrae belonging to other Oostheroff groups (OoInt and OoIII) are instead not well reproduced. While for OoIII clusters a larger helium abundance for a fraction of the cluster's stars can reconcile the model prediction with observations, some other parameter affecting both the Horizontal Branch morphology and the RR Lyrae periods is required to reproduce the behavior of OoInt clusters.