My informant is my brother-in-law, who grew up in the suburbs of Dallas, Texas. He says he frequently heard his father tell him this, who would invoke the proverb to warn him against hanging out with the wrong crowd. He is of Western European descent and identifies as American.
This is a proverb, so the text remains largely the same with each iteration of speech. This proverb is used as a warning against associating with the wrong people.
“If you lie down with dogs, you’ll get fleas.”
As a proverb is supposed to convey some sort of wisdom or inherent truth, this proverb serves as a warning. It is common in English to hear a person refer to another person who is perceived as having a low moral character as a “dog.” This is likely due to dogs historically subsisting off of food scraps and scavenging in the cities and villages of human settlements. Dogs have a reputation of being dirty scavengers, and so the application to those with low moral standing is apparent. And, since dogs often have fleas, something that is unpleasant to be afflicted with, the proverb has both literal and metaphorical meaning. From here, it is easy to see how the proverb serves its warning: associating with those with low moral standing is likely to influence one’s own behavior.
The “dogs” might also refer to those of low socioeconomic standing, however, especially given the association with fleas. Fleas can be seen as a disease or affliction, and the proverb might also be meant to warn against associating with those with poor hygiene due to economic factors. On a larger societal level, this proverb might serve to maintain social boundaries based on class.