Avail: use, benefit, or advantage. To no avail would be, then, to no use, benefit, or advantage. Nothing useful came out of the attempt; it was unsuccessful. It is similar, then, to futile.
How do you know something is in vain unless you've tried? Futile and vainly connote an attempt:
All his efforts were in vain; resistance was futile.
In your second 'definition', you are assuming the chances are so remote one doesn't even try. That is not in vain or futile. That is impossible, in which case attempting something would be foolish. As in the following (vainly is misused):
His vainly attempted to walk across the Pacific Ocean.
A good dictionary should give you the denotation (exact definition) of a word, as well as, somewhere among the synonyms, the connotation of a word. The latter is where the subtlety and elegance of words lie.
Synonyms for pointless or impossible:
senseless, meaningless, stupid, silly, useless, absurd, irrelevant, worthless, nonsensical, inane, without rhyme or reason.
Edited to add: I read the poem The Garden. It is about the contrasted virtues of the active and the contemplative life. The last couplet (which became a standard sundial inscription) is "How could such sweet and wholsome Hours / Be reckon'd but with herbs and flow'rs!"
As the active life is being criticized, it is in the sense of men not finding contentment except in 'the Garden' (originally that of Eden). Vainly men seek contentment in worldly pursuits. That is not proudly but unsuccessfully.