Not just the fourth finger, but the whole structure of the wing, must have developed with chance mutations, and this whole process would have had to bring some advantage to the creature.