There are 2 versions of this story
The story that all you know :
Himym : The tie is originally worn by Marshall, but after making fun of it, Barney ends up having to wear the ducky tie as a result of losing a bet with Marshall and Lily. ... According to the bet Barney has to wear it for a whole year, but in Disaster Averted, he tries to get out of wearing it for the rest of the year.It is even seen wrapped around Barney's arm in The Slutty Pumpkin Returns, when Barney turns up almost naked in the Halloween Party on the roof of The Apartment.
It was first seen in the following episode during a flashforward of Marshall and 's trip to Atlantic City
As indicated by the bet Barney needs to wear it for an entire year, however in Disaster Averted, he attempts to escape wearing it for the remainder of the year. He even offers Marshall a ton of money in the event that he allows him to take it off. It just so happens, Barney needs to take it off in light of the fact that he is meeting Nora's parents and he needs to establish a decent connection. At the point when Marshall looks into this, he allows Barney to take the tie off in return for the expansion of three additional slaps to his one last slap. Barney consents to this, yet when Marshall quickly slaps him twice from that point onward, he understands that he committed an error.
The story that you didn't know :
Marshall and Lily bet :
Lily and Marshall made a secret bet to make Barney look stupid with the ducky tie
She didn't know anyway how to do it and she simply made Marshall wearing it all the time,hopfully
Barney will like it. So she could win the 20$ bet with Marshall.
Barney as we know , he was thinking to make a joke ( thought long time ago ) so he could win a bet with marshall.
What the series doesn't show that lily tried to make barney wear the dukcy tie for the hole week but without success . At the last moment at Shinjitsu , Lily catches the chance by making a counter bet .Knowing what she was risking...
All we know how the story ends.
Real Story as Barney Stinson says
If you liked this , read my other post they are pretty funny