Egregious
mid 16th century (in egregious (sense 2)): from Latin egregius ‘illustrious’, literally ‘standing out from the flock’, from ex- ‘out’ + grex, greg- ‘flock’. Sense 1 (late 16th century) probably arose as an ironic use.
wiktionary
From Latin ēgregius, from e-(“out of”), + grex(“flock”), + English adjective suffix -ous, from Latin suffix -osus(“full of”); reflecting the positive connotations of "standing out from the flock".
etymonline
egregious (adj.)
1530s, "distinguished, eminent, excellent," from Latin egregius "distinguished, excellent, extraordinary," from the phrase ex grege "rising above the flock," from ex "out of" (see ex-) + grege, ablative of grex "a herd, flock" (from PIE root *ger- "to gather").
Disapproving sense, now predominant, arose late 16c., originally ironic. It is not in the Latin word, which etymologically means simply "exceptional." Related: Egregiously; egregiousness.