It is two words: Good luck. I wouldn't say it was an idiom - as it is quite literal in its meaning.
When you say it, you are telling someone that you hope they have good luck in what they are about to do. We often say it to someone when they are doing something new, or different, where luck might make a difference to the outcome.
"Good luck with that exam tomorrow". You would say it to a friend who has told you that he is going to ask a girl out. Most people that sell you a lottery ticket would say it to you.