The word 'chief' derives from Old French chief "leader, ruler, head", as you know. This word in Old French evolved into the Modern French word 'chef' (as you probably also know).
Now, in French, the phrase 'en [something]' very roughly translates to 'in [something]". In reality the preposition 'en' is a really slippery thing to translate, and can mean "at", "as", "(made out) of", "while", "via", etc. but its main use is in describing the qualities of things. 'en guerre' means "at war", 'en fait' means "in fact", 'en colère' means "in rage (angry)", 'en route' means, well, "en route (on the way)". English has borrowed a lot of things from French, one of its closest neighbors, and a lot of these 'en [something]' phrases have made their way into English one way or another.
You probably see where I'm going with this. The phrase 'en chef', literally "in chief", means "chief" or "head". 'Infirmier en chef' means "head nurse", 'ingénieur en chef' means "chief engineer", and of course, 'commandant en chef' means "commander in chief". So in English the phrase "in chief" has gained the meaning of "head", "principal", and by extension "primary" or "main".
What is an 'examination-in-chief'? It's the questioning of a witness by the party (the defense, the prosecution) that has called that witness to the stand. It's the "principal examination" taking place, and the cross-examination afterwards to clear up loose ends is secondary to it. So the phrase 'in-chief' is attached to the word "examination".