This is well-known and virtually all good grammars discuss this (as vowel syncope).
Genetivus singularis helps us reconstruct the original nom.sg. form (synchronically), that's why we learn nouns in Latin in two forms, nominativus singularis and genetivus singularis.
Type A. No change, the vowel was present in all forms.
Nom. sg. pueros > *puers > puer
Gen. sg. pueri
Type B. Originally, there was no e in Nom. sg.
Nom. sg. agros > *agrs > ager
Gen. sg. agri
Data from Old Latin and other Indo-European languages (especially Ancient Greek) confirms this.
Environment:
consonant + *-ros, e.g. SAKROS > sacer (cf. ferus);
vowel + *-ros (in trisyllabic words, short penult), e.g. *vesperos > vesper (cf. sincerus)
etc.
For further details see Weiss 2009/2011, Chapter 23; Baldi 2002: 313; Meiser 1998, §55.1, and Sihler §74.4.