English is a complex language, and even those of us who were born and raised with it, can still be confused when it comes to proper spelling and punctuation of certain terms and phrases.
Saying “goodnight” is a way to send someone off to bed. When spelled as one word, “goodnight” is a standard salutation that sends someone off in a pleasant manner.
I gave her a goodnight kiss and wished her happy dreams.
“Good night” is a phrase with two separate parts. The first, “good”, is an adjective. It modifies the noun and subject of the sentence, which is “night”. You can use it in a sentence, i.e., “It was a good night”, or you can say it while departing after spending an evening with someone. In this case, “Good night” would be short for “Have a good night.”
“Good-night” hyphenated isn’t grammatically correct, since you don’t need to add a hyphen to modify the subject of “night”. If you want to talk about a night that was enjoyable, you can simply write “good night”. If you want to say goodbye to someone after evening hours, it works just as well.
Although people tend to accept either “goodnight” or “good night” and the opinions on their proper usage vary, using “goodnight” to wish someone a peaceful sleep and “good night” as a departure is one easy way to distinguish the two.