In nominative:
Доброе утро (утро is a neuter noun)
Добрый день, добрый вечер (день and вечер are masculine nouns).
Добрая ночь (ночь is feminine).
In genitive:
Доброго утра, доброго дня, доброго вечера,
Доброй ночи.
Now, I don't know the history of 'good day' (or morning/evening alike) greeting and why it most often comes in nominative. In modern Russian in nominative it sounds like a constatation:"the day is good".
As to genitive in "доброй ночи" (or, more common when the pesron is expected to go to bed soon: "спокойной ночи") - it is clear.
Russian verbs mening 'to wish [somebody something]' are used with this 'something' in genitive:)
Often we omit the verb.
So "доброй/спокойной ночи" is understood as a wish: 'have a good/calm night'.