"Le" is a direct object pronoun; "lui" is an indirect object pronoun.
A direct object receives the action if the verb, while an indirect object is who the action is done to.
What am I wishing? A good night.
Who/what am I wishing to? Him.
Since "him" is the indirect object, you use lui instead of le. Hope this wasn't too confusing :/
- I wish her a good night - je lui souhaite une bonne nuit
- I wish him a good night - je lui souhaite une bonne nuit.
'lui' means 'him' or 'her' depending on the context. the pronoun 'lui' does not refer to 'nuit', but to the person you wish a good night to.
'nuit' meaning night is always female in french. therefore it is 'la bonne nuit'.