The noun foedus originally (by which I mean late Proto-Italic going into early Latin) looked something like *foidos-. Note that that's the stem, with no ending attached.
Proto-Indo-European ablaut patterns would have meant the stem was *foidos- in the nominative and vocative and *foides- in the other cases, but I'm not sure if this ablaut was still relevant in Proto-Italic or if it had been levelled out; this answer is written as if it were already levelled out, for simplicity. The result is the same either way.
The third-declension endings were then added onto this. (I'm only showing the nominative, genitive, and ablative, but you can extrapolate the rest.)
Note that the nominative ending for neuter third-declension nouns is ∅ (that is, nothing at all). Then rhotacism applied, changing S between vowels to R.
Another process turned all short vowels in medial open syllables (i.e. vowels in the middle of a word and not before two consonants) into i. But Latin didn't like ir, so this sequence became er. Note that this happened no matter what the vowel was, so it doesn't matter if the PIE ablaut was still relevant or not.
Finally, short o in the last syllable of a word turned into u, short e in closed final syllables turned into i, and oi was respelled oe.
This led to the noun forms you're familiar with in Classical times.
The adjective foedus came from a different source: its stem was actually foid- instead of foidos-, and the standard first/second endings were tacked onto this.