"Many nouns get an -n ending in the plural, for example "die Affen", "die Studenten" and "die Russen". In most cases the -n ending applies in the nominative, accusative and dative, but some nouns only receive the -n ending in the dative, for example "die Jahre(n)". Why is this?
German nouns can be roughly divided into:
Weak nouns with plural and genitive ending with -en, example: Der Hase, plural die Hasen, genitive des Hasen.
Strong nouns with other nominative plural endings (such as -e or -er, sometimes with umlaut) and a genitive usually ending with -es or -s, example: Der Tag, plural die Tage, genitive des Tages.
There are also mixed cases, for example das Herz, plural die Herzen, but genitive des Herzens.
In all cases the dative plural ends with -en (or -n).
These forms have their origin in the declension classes of Old High German which originate in Germanic declension classes which in turn originate in Indo-European classes. The strong declension emerged out of vocalic declensions and the weak declension emerged out of the consonantic declension which in turn have their origin in the Indo-European thematic and athematic stems.
A good German dictionary contains the genitive and plural ending of each noun, which is generally sufficient to derive all forms.
A list of all weak or strong nouns would be very large and of little practical value, so I would advise to consult a dictionary and look at the genitive and plural endings supplied.