Keep your distance
Observe the avoidance of familiarity which is appropriate to one's position. Also, in more recent usage, to remain aloof and detached from another person or situation.
In its original form this expression related to maintaining a distance from another person. This wasn't just a matter of keeping any old distance but specifically keeping your distance. The implication seems to be that the distance in question was different for different people, and that's exactly the meaning that was intended.
The phrase originated in England of the 17th century and the etiquette of the day required people to know their place. 'Knowing your place' had a more literal meaning then than it does now and 'one's place' was a physical space that one was expect to occupy; in particular people weren't permitted to encroach on the personal space of their betters. This convention is encapsulated in phrases like 'below/above stairs' and 'below the salt'. So, 'one's distance' might be a short one between two people of the same class but much larger between those of different stations in society. Amongst the Tudor aristocracy servants 'should be seen and not heard' - a requirement that the Victorians later applied to children.
Shakespeare was the first to refer to people maintaining their appropriate distance, in All's Well that ends Well, 1616:
She knew her distance, and did angle for mee, Madding my eagernesse with her restraint.
Other examples of the 'knowing' of one's proper distance that make clear the propriety of maintaining it are:
Massinger's The Parliament of Love, 1624 - "Pray you keepe your distance, And grow not rude."
Walker's History of Independency, 1660 - "They intended to curb the Wallingford party, by teaching them manners, and to know their distance."
The earliest usage of the precise expression 'keep your distance' that I have found in print is in Oliver Goldsmith's She Stoops to Conquer, 1773:
"It won't do, so I beg you'll keep your distance."
The use of the expression these days reflects the change in social norms. We are now less commonly required to stand apart from people that are seen as our betters. In current usage 'keeping one's distance' is usually used to mean avoiding being friendly or getting close to others.