If you do something in vain, you do it with no result, or to no effect. Abraham Lincoln delivered the Gettysburg Address to make it clear that Union soldiers did not die in vain.
If an effort is futile, it's in vain. You might spend time and money campaigning to be school president, handing out bumper stickers and homemade cupcakes, all in vain — despite your hard work, you don't win the election. When you wait in vain for the phone to ring, it never does. In vain is modeled after the Latin in vanum, and it keeps the original sense of the word vain, "unprofitable" or "devoid of value."