"Is it kind of like a programmed social contract": Yes and no. It is an example of "well wishing". Other examples would be saying "have a good day", "have safe travels (bon voyage)", etc. Behind that comes the question of sincerity / authenticity. Chances are when a greeter / sales clerk at a big box stores says "Have a good day", etc. there is little sincerity behind it. Between that and repetition of similar well wishes, there does exist a social expectation (if someone says to you "happy new year", there is an expectation of a similar well wish).
Being on the autistic spectrum, I never understood it. Is it kind of like a programmed social contract, like sharing in the humor of looking at a lolcat? Is that why such sentiments get upvoted like lolcats?