The origins of the term are unclear. It's generally believed it originated from the carnival, back in the days when wrestlers were part of travelling troupes. It's most likely a play on the word "fake!" (https://www.merriam-webster.com/words-at-play/word-origin-kayfabe#:~:text=Although%20coined%20in%20the%20late,in%20keeping%20with%2C%20pig%20Latin.)
(I don't remember my source for this, but I'm pretty sure I heard it from an interview with a wrestling insider) Before the late 90's, if people inside the wrestling industry were talking shop, and they notice an outsider (friend, spouse, etc.) approaching, one of them would shout "kayfabe!" to warn the others.