[proofplan]
The Killing form is nondegenerate by Cartan's criterion for finite-dimensional semisimple Lie algebras in characteristic $0$, so every basis has a unique Killing-[dual basis](/theorems/414). We first express the tensor $\sum_i e_i\otimes e^i$ as the inverse tensor of the Killing form, which proves basis-independence before passing to $U(\mathfrak g)$. We then use [invariance of the Killing form](/theorems/3808) to show that this inverse tensor is fixed by the diagonal adjoint action. Multiplication in the universal enveloping algebra converts this diagonal action into the commutator action, so the resulting element commutes with every element of $\mathfrak g$, and therefore with all of $U(\mathfrak g)$.
[/proofplan]
[step:Identify the inverse Killing tensor independently of the chosen basis]
By Cartan's criterion for finite-dimensional semisimple Lie algebras over fields of characteristic $0$ (citing a result not yet in the wiki: Cartan criterion for semisimple Lie algebras), the Killing form $B$ is nondegenerate. Hence the $k$-[linear map](/page/Linear%20Map)
\begin{align*}
\beta:\mathfrak g\to \mathfrak g^*
\end{align*}
defined by
\begin{align*}
\beta(X)(Y)=B(X,Y)
\end{align*}
is an isomorphism.
Define the $k$-linear map
\begin{align*}
\Lambda:\mathfrak g\otimes_k \mathfrak g\to \operatorname{End}_k(\mathfrak g)
\end{align*}
on pure tensors by
\begin{align*}
\Lambda(a\otimes b)(Y)=B(b,Y)a
\end{align*}
for all $a,b,Y\in\mathfrak g$. This is an isomorphism because it is the composite of the isomorphism $\operatorname{id}_{\mathfrak g}\otimes \beta:\mathfrak g\otimes_k\mathfrak g\to \mathfrak g\otimes_k\mathfrak g^*$ with the standard evaluation isomorphism $\mathfrak g\otimes_k\mathfrak g^*\to \operatorname{End}_k(\mathfrak g)$.
Let
\begin{align*}
T=\sum_{i=1}^{n} e_i\otimes e^i\in \mathfrak g\otimes_k\mathfrak g.
\end{align*}
For each $j\in\{1,\dots,n\}$, symmetry of the Killing form gives
\begin{align*}
\Lambda(T)(e_j)=\sum_{i=1}^{n} B(e^i,e_j)e_i=\sum_{i=1}^{n} B(e_j,e^i)e_i=e_j.
\end{align*}
Since $(e_1,\dots,e_n)$ is a basis of $\mathfrak g$, it follows that $\Lambda(T)=\operatorname{id}_{\mathfrak g}$. Therefore
\begin{align*}
T=\Lambda^{-1}(\operatorname{id}_{\mathfrak g}),
\end{align*}
so $T$ is independent of the chosen basis.
[/step]
[step:Show that the inverse Killing tensor is fixed by the diagonal adjoint action]
For each $X\in\mathfrak g$, define the $k$-linear map
\begin{align*}
D_X:\mathfrak g\otimes_k\mathfrak g\to \mathfrak g\otimes_k\mathfrak g
\end{align*}
on pure tensors by
\begin{align*}
D_X(a\otimes b)=[X,a]\otimes b+a\otimes [X,b].
\end{align*}
We prove that $D_X(T)=0$.
The Killing form is invariant: for all $A,B_1,B_2\in\mathfrak g$,
\begin{align*}
B([A,B_1],B_2)+B(B_1,[A,B_2])=0.
\end{align*}
For $a,b,Y\in\mathfrak g$, this gives \begin{align*}\Lambda(D_X(a\otimes b))(Y)=B(b,Y)[X,a]+B([X,b],Y)a.\end{align*}
Using invariance again, $B([X,b],Y)=-B(b,[X,Y])$, so \begin{align*}\Lambda(D_X(a\otimes b))(Y)=B(b,Y)[X,a]-B(b,[X,Y])a.\end{align*}
The right-hand side is exactly \begin{align*}(\operatorname{ad}_X\circ \Lambda(a\otimes b)-\Lambda(a\otimes b)\circ \operatorname{ad}_X)(Y).\end{align*}
Thus \begin{align*}\Lambda(D_X S)=\operatorname{ad}_X\circ \Lambda(S)-\Lambda(S)\circ \operatorname{ad}_X\end{align*} for every $S\in\mathfrak g\otimes_k\mathfrak g$. Applying this to $S=T$ and using $\Lambda(T)=\operatorname{id}_{\mathfrak g}$ gives \begin{align*}\Lambda(D_XT)=\operatorname{ad}_X-\operatorname{ad}_X=0.\end{align*}
Since $\Lambda$ is injective, $D_XT=0$.
[guided]
The point of this step is to translate invariance of the Killing form into invariance of the inverse tensor $T$. For each $X\in\mathfrak g$, we define
\begin{align*}
D_X:\mathfrak g\otimes_k\mathfrak g\to \mathfrak g\otimes_k\mathfrak g
\end{align*}
by
\begin{align*}
D_X(a\otimes b)=[X,a]\otimes b+a\otimes [X,b].
\end{align*}
This is the diagonal adjoint action on the [tensor product](/page/Tensor%20Product): $X$ acts on the first factor and on the second factor, and the two contributions are added.
We want to prove $D_X(T)=0$. Instead of computing directly in a basis, we use the isomorphism
\begin{align*}
\Lambda:\mathfrak g\otimes_k\mathfrak g\to \operatorname{End}_k(\mathfrak g)
\end{align*}
defined by
\begin{align*}
\Lambda(a\otimes b)(Y)=B(b,Y)a.
\end{align*}
Since $\Lambda(T)=\operatorname{id}_{\mathfrak g}$, it is enough to understand how $D_X$ appears after applying $\Lambda$.
Let $a,b,Y\in\mathfrak g$. By the definition of $D_X$ and $\Lambda$,
\begin{align*}
\Lambda(D_X(a\otimes b))(Y)=B(b,Y)[X,a]+B([X,b],Y)a.
\end{align*}
The second term is the only place where invariance of the Killing form is used. Invariance says
\begin{align*}
B([X,b],Y)+B(b,[X,Y])=0,
\end{align*}
and hence
\begin{align*}
B([X,b],Y)=-B(b,[X,Y]).
\end{align*}
Substituting this into the previous formula gives
\begin{align*}
\Lambda(D_X(a\otimes b))(Y)=B(b,Y)[X,a]-B(b,[X,Y])a.
\end{align*}
Now compare this with the commutator of endomorphisms. Since
\begin{align*}
\Lambda(a\otimes b)(Y)=B(b,Y)a,
\end{align*}
we have
\begin{align*}
(\operatorname{ad}_X\circ \Lambda(a\otimes b))(Y)=B(b,Y)[X,a],
\end{align*}
and
\begin{align*}
(\Lambda(a\otimes b)\circ \operatorname{ad}_X)(Y)=B(b,[X,Y])a.
\end{align*}
Therefore
\begin{align*}
\Lambda(D_X(a\otimes b))(Y)=(\operatorname{ad}_X\circ \Lambda(a\otimes b)-\Lambda(a\otimes b)\circ \operatorname{ad}_X)(Y).
\end{align*}
By linearity, for every $S\in\mathfrak g\otimes_k\mathfrak g$,
\begin{align*}
\Lambda(D_XS)=\operatorname{ad}_X\circ \Lambda(S)-\Lambda(S)\circ \operatorname{ad}_X.
\end{align*}
Apply this identity to $S=T$. Since $\Lambda(T)=\operatorname{id}_{\mathfrak g}$,
\begin{align*}
\Lambda(D_XT)=\operatorname{ad}_X\circ \operatorname{id}_{\mathfrak g}-\operatorname{id}_{\mathfrak g}\circ \operatorname{ad}_X=0.
\end{align*}
The map $\Lambda$ is injective, so
\begin{align*}
D_XT=0.
\end{align*}
Thus the inverse Killing tensor is fixed by the diagonal adjoint action of every $X\in\mathfrak g$.
[/guided]
[/step]
[step:Convert diagonal adjoint invariance into commutation in the enveloping algebra]
Let
\begin{align*}
m:\mathfrak g\otimes_k\mathfrak g\to U(\mathfrak g)
\end{align*}
be the $k$-linear map defined on pure tensors by
\begin{align*}
m(a\otimes b)=ab,
\end{align*}
where $ab$ denotes multiplication in $U(\mathfrak g)$. By definition,
\begin{align*}
C=m(T).
\end{align*}
Fix $X\in\mathfrak g$. In $U(\mathfrak g)$, the defining relation is \begin{align*}XY-YX=[X,Y]\end{align*} for all $Y\in\mathfrak g$. Hence, for all $a,b\in\mathfrak g$, \begin{align*}[X,ab]=Xab-abX.\end{align*}
Adding and subtracting $aXb$ gives \begin{align*}[X,ab]=(Xa-aX)b+a(Xb-bX).\end{align*}
Using the defining relation again, \begin{align*}[X,ab]=[X,a]b+a[X,b].\end{align*}
Therefore, for every $S\in\mathfrak g\otimes_k\mathfrak g$, \begin{align*}[X,m(S)]=m(D_XS).\end{align*}
Applying this to $S=T$ and using $D_XT=0$ gives \begin{align*}[X,C]=[X,m(T)]=m(D_XT)=0.\end{align*}
Thus $C$ commutes with every $X\in\mathfrak g$.
[/step]
[step:Conclude that the Casimir element is central]
The universal enveloping algebra $U(\mathfrak g)$ is generated as a unital associative algebra by the image of $\mathfrak g$. We have proved that $C$ commutes with every generator $X\in\mathfrak g$, and $C$ also commutes with the unit element $1\in U(\mathfrak g)$.
If $Y_1,\dots,Y_r\in\mathfrak g$, then repeated use of $CY_j=Y_jC$ gives
\begin{align*}
C(Y_1Y_2\cdots Y_r)=Y_1Y_2\cdots Y_r C.
\end{align*}
By $k$-linearity, $C$ commutes with every finite $k$-linear combination of such products, hence with every element of $U(\mathfrak g)$. Therefore
\begin{align*}
C\in Z(U(\mathfrak g)).
\end{align*}
The first step already proved that $T=\sum_i e_i\otimes e^i$ is independent of the basis, and since $C=m(T)$, the element $C=\sum_i e_i e^i$ is also independent of the chosen basis. This proves both asserted properties of the quadratic Casimir element.
[/step]