The etymology of the ending "-keit" is rather complicated, as we have influences from a different pronunciation in High German vs. Low German dialects here.
Example "Ewigkeit":
Up until today the adjective ending "-ig" is pronounced differently in northern and southern regions. See for example "ewig":
- Pronunciation in standard German: [ˈeːvɪç] (same a ch in "Ich").
- Pronunciation in Swabia: [ˈeːvɪk] (same as ck in "dick").
Now, for "ewig" the pronunciation in Old High German was different from today, as we can see from the Middle High German spelling ewic, or ewik. The adjective was then nominalized using the common suffix "-heit" to give Ewic-heit which then became Ewikeit by dropping the h on pronunciation.
Only later the now missing g from "ewig" was reintroduced to become "Ewigkeit". Until today this added g curiously is pronounced as "ch" in standard German: [ˈeːvɪçkaɪ̯t]. Interestingly in many German dialects "Ewigkeit" is still pronounced as [ˈeːvɪkaɪ̯t], i.e. the g introduced from spelling is ignored.
Other variants
This phenomenon happened to many adjectives, including other adjectives that did not end on -ic leading to an independent additional suffix -keit, and even another independent suffix -igkeit was introduced (e.g. "Gerechtigkeit", "Farbigkeit"). In other cases the -keit suffix was dropped again for -heit (e.g. rein > Reinic-heit > Reinekeit > Reinheit), or both suffixes coexisted at times (Frommheit - Frömmigkeit, Munterheit - Munterkeit). On top of all this confusion it may also be that when pronounced as ch the ending may also be spelt with ch (vrœlīc-heit > Fröhlichkeit).
For a concise insight into the etymology of "-keit" and many more examples see:
Indo-European etymology
In Old High German -heit already is present, sharing it's roots with the adjective heiter, and the Old Saxonian hēd, Old English hād, Gothic haidus, and Old Norsk heiðr. All these, and Old Indian kētúḥ, or Latin caelum probably go back to a common Indo-European root (s)kāi-.DWDS
Summary
In summary we can see that the suffix -keit shares the same etymology with -heit but it's spelling changed over time.