It may also have something to do with being around farms and farm animals.
I remember reading that exposure to the farm environment allows the developing child's immunity system to deal with common ailments which are out and about in the world.
Similar to minimal exposure leads to immunity concept of vaccines.
I just mention it to add to the discussion.
Very good connection you made! But vaccination amounts to OVERKILL and overwhelms the body's immune system. A better analogy (or what the barnyard immunity more actually is) would be homeopathy, which INDUCES the body's own immune system rather than overwhelming it with a foreign invader.