It would be used as a self-deprecating comment, meaning that your actions did not have much influence on a successful outcome.
For example, you are selected for a better job. If someone asks how did you get the job, instead of saying, "Because I worked hard", you might just say "I just got lucky."
It is often used so people do not think you are boasting.