Here's the story behind the "Mermaid Theory" in How I Met Your Mother. The theory was created by Barney Stinson (Neil Patrick Harris) and it - unsurprisingly - involved his skewed perception of women. He explained the theory when Marshall and Robin made it a point to spend more time together.
Barney was one of the biggest womanizers in TV history. He had a habit of treating women as objects rather than humans, something that Lily (Alyson Hannigan) often called him out for. Barney had many wild theories and strange misconceptions when it came to the opposite sex. He even had a Playbook with detailed "plays" in how to win over women. The Mermaid Theory was just one of the beliefs that Barney had when it came to understanding women.
The Mermaid Theory was introduced in How I Met Your Mother season 6. The theory suggested that a man will eventually have the urge to sleep with any woman he hangs out with over a period of time, no matter how incompatible she initially seems. Barney's title for the theory came from sailors who would spend so much time at sea that they would confuse manatees for beautiful mermaids. He made a point to add that the specific women would turn back into a manatee if she got pregnant.
The theory came into play when Marshall and Robin (Jason Segel and Cobie Smulders) realized that they never spend any time together alone as friends. Marshall believed that the attractiveness rules with female friends changed after being married, so they decided to have dinner together but the outing was very awkward. Marshall explained Barney's Mermaid Theory as the reason he didn't hang out with Robin as he worried that he would eventually be attracted to her. Later in the night, Marshall was horrified to see that Robin started to have mermaid qualities. After she threw up on him, however, she turned back into a manatee (literally), much to Marshall's relief.
Later in the episode, Future Ted (Josh Radnor) tried to recall an argument between Barney and Lily. He admitted to mixing up some of the details but it boiled down to Lily being offended after Barney called her a manatee. She felt that they couldn't hang out together because he always undressed her with his eyes. Lily was actually pregnant at the time so, according to his theory, he wouldn't view her in that way. She later forgave Barney when he told her that she would transform back into a mermaid when she started to breastfeed.
Barney's Mermaid Theory may sound crazy and be rooted from an insensitive perception but it closely resembles a real psychological phenomenon, the mere-exposure effect. The belief suggests that repeated exposure to something makes one like it more. So technically, in the case of Barney or another character in How I Met Your Mother, being around a woman for an extended time could result in a change of attraction. Barney might have questionable beliefs but he might have been onto something with the Mermaid Theory.