It means that when one decides to do something dishonest or evil (like the devil), plans are made, lies are told, people and facts are manipulated. But something always happens to foil the plan. The truth comes out, or the wrongdoer is punished, or the plans fail. It is similar to the saying according to which there is no perfect crime.