Y in English lost it's value as a front-of-mouth u (a.k.a. the i umlaut of u or close [or high] front rounded vowel) in the dominant "official" dialects in the late OE period, and was generally replaced in spelling by i. Naturally some scribes persisted with the y spelling despite the change in speech longer than others.
the change from g to gh to indicate the change to an aspirate occurs from late Middle English to early modern English. The form ʒ, ȝ and similar (derived from g) called yogh was used from the middle English period to also represent both front g (pronounced as y) and the aspirate. This yogh is then replaced (not all at once) with simplification of the alphabet (moveable type is partly to blame, although it occurs earlier) by y and gh in common words. although sometimes s (in demesne, in a deliberate archaism where yogh was never used, the earlier spelling being demeine) and z (mostly in names such as Menzies [pronounced Menyes] and Dalziel [Dai:yel]) are used.
"Apothegm" is an American simplification, made by some writers and editors. As the roman transliteration of a foreign word it doesn't follow normal English orthography.