From Latin 'not pertaining to' — originally meant 'irrelevant,' shifted to 'rude' because off-topic remarks were seen as disrespectful.
Not showing proper respect; rude; insolent. Also (now rare): not pertinent; irrelevant.
From Proto-Indo-European *per- ("forward, through") + *ten- ("to stretch"), via Latin impertinens, composed of im- (negative prefix) + pertinens ("pertaining, relevant"), present participle of pertinere ("to stretch toward, to belong to, to be relevant"). Pertinere literally means "to stretch all the way to" — to be relevant, connected, applicable. Impertinent therefore originally meant simply "not relevant, not pertaining to the matter" — a neutral logical term used in medieval scholastic philosophy and law. The shift to "rude, presumptuous, insolent" happened in 17th-century English as irrelevant things
In Shakespeare's time, 'impertinent' still carried both meanings — irrelevant and rude — and he exploited the ambiguity. In 'The Tempest,' Prospero dismisses something as 'impertinent,' and audiences cannot be certain whether he means 'beside the point' or 'insolent.' The double meaning allowed for layers of dramatic irony that the modern single meaning forecloses.