To defy is to openly refuse to do something. You can defy the no-costumes-in-class rule if you wear your fairy wings to school, but just don’t try to defy the laws of gravity unless you can actually fly.
If you deliberately break a rule or ignore an order, you defy, or resist, that rule. The word defy comes from the Latin word disfidare for "renounce one's faith." So if you're expected to be faithful to a certain law or rule but you refuse to be, you defy it. There are different ways to defy — defy your parents by staying out past curfew, or defy common sense by walking in with shoes on your head.