This is a great idiom, quite informal but good to use. We use 'When pigs fly' to say that someone has said something unbelievable and you really don't expect this to happen in the future. The thing they have said is very 'far-fetched' and the action suggested is NEVER going to happen in your opinion.
You think you will win the lottery this weekend? Yes and pigs may fly! It isn't going to happen!
There's no way you'll get an A grade, you haven't done any work at all! Pigs might fly before that happens!
There's no way that girl will like you, pigs might fly before she agrees to go on a date with you!
As you can see it's very strong and be careful how you use it!