Because pigs sprouting wings and flying around is very unlikely. Therefore whatever they are referring to will most likely never happen. It’s something I heard a lot when I was a kid.
Example: Dad, Can I have a raise in my allowance? Dad: Sure, when pigs start flying and the grass turns blue.
Because, it's sort of being sarcastic. If someone said they'll do something "when pigs fly" its basically saying they're never going to do that thing, because flying pigs are impossible. Either that or they're kind of saying that something is never going to happen.