Suppose that $h:k^S\to k$ is a $k$-algebra homomorphism. For $A\subseteq S$ let $\chi_A\in k^S$ be defined by $\chi_A(s) = \begin{cases}1_k,& s\in A\\ 0_k,& s\in S\setminus A\;.\end{cases}$ Let $\mathscr{U}=\{A\subseteq S:h(\chi_A)\ne 0_k\}$.
If $A,B\in\mathscr{U}$, $\chi_{A\cap B} = \chi_A \chi_B$, so $h(X_{A\cap B}) = h(\chi_A)h(\chi_B) \ne 0_k$, and hence $A\cap B \in \mathscr{U}$. Now suppose that $A\in \mathscr{U}$ and $A \subseteq B \subseteq S$; then $\chi_A = \chi_A \chi_B$, so $0_k \ne h(\chi_A) = h(\chi_A)h(\chi_B)$, and therefore $h(\chi_B) \ne 0_k$, i.e., $B \in \mathscr{U}$. This shows that $\mathscr{U}$ is a filter on $S$.
Finally, let $A\subseteq S$, and for brevity let A'=S\setminus A. \chi_A \chi_{A'} = 0_{k^S}, so h(\chi_A)h(\chi_{A'})=h(0_{k^S})=0_k, and hence at most one of $A$ and A' belongs to $\mathscr{U}$. On the other hand, \chi_A+\chi_{A'}=1_{k^S}, so h(\chi_A) + h(\chi_{A'}) =h(1_{k^S})=1_k, and at least one of $A$ and A' belongs to $\mathscr{U}$. Thus, $\mathscr{U}$ is an ultrafilter on $S$. We can go further: since we already know that either $h(\chi_A)=0_k$ or h(\chi_{A'})=0_k, we can conclude that for each $A\subseteq S$, $A\in \mathscr{U}$ iff $h(\chi_A)=1_k$.
Let $I=\{\varphi\in k^S:Z(\varphi)\in\mathscr{U}\}$, where $Z(\varphi)=\{s\in S:\varphi(s) = 0_k\}$. It’s easy to check that $I$ is an ideal in $k^S$. $I$ is proper, since $\chi_S \notin I$. Moreover, $I$ is maximal. To see this, suppose that $J\supsetneq I$ is also an ideal, and fix $\varphi \in J\setminus I$. Then $Z(\varphi)\notin \mathscr{U}$, so $S\setminus Z(\varphi) \in \mathscr{U}$, and $\chi_{Z(\varphi)} \in I$ (since $Z(\chi_A) = S\setminus A$ for any $A\subseteq S$). It follows that $\varphi + \chi_{Z(\varphi)} \in I$. But $Z(\varphi + \chi_{Z(\varphi)}) = \varnothing$, so $\varphi + \chi_{Z(\varphi)}$ has a multiplicative inverse, and therefore $1_{k^S} \in J$.
Now let $\varphi \in I$, and let $\psi \in k^S$ be defined by $\psi(s) = \begin{cases} \varphi(s)^{-1},&s\in S\setminus Z(\varphi)\\ 0_k,&s\in Z(\varphi)\;; \end{cases}\tag{1}$ then $h(\varphi)h(\psi) = h(\chi_{S\setminus Z(\varphi)}) = 0_k$, so $h(\varphi)=0_k$ or $h(\psi)=0_k$. Say $h(\psi)=0_k$. Then $h(\chi_{Z(\varphi)} + \psi) =$ $h(\chi_{Z(\varphi)}) + h(\psi) = 1_k$, so $h(\varphi) = h((\chi_{Z(\varphi)}+\psi)\varphi) = h(0_{k^S}+\chi_{S\setminus Z(\varphi)}) = 0_k$. Thus, $I \subseteq \ker h$. Conversely, suppose that $h(\varphi) = 0_k$. Define $\psi$ as in $(1)$. Then $h(\chi_{S\setminus Z(\varphi)}) = h(\varphi)h(\psi) = 0_k$, so $Z(\varphi) \in \mathscr{U}$, and $\varphi \in I$. Thus, $I = \ker h$, and $k \cong k^S/I$.
Now suppose that $|S|<|k|$, and let $\varphi \in k^S$ be an injection. Let $\alpha = h(\varphi)$, and let $\psi = \alpha \cdot 1_{k^S}$. Then $h(\psi) = \alpha$, so $\varphi - \psi \in \ker h = I$, and therefore $Z(\varphi - \psi) \in \mathscr{U}$. But since $\varphi$ is injective and $\psi$ is constant, $|Z(\varphi - \psi)|\le 1$. $\varnothing \notin \mathscr{U}$, so $Z(\varphi - \psi) = \{s_0\}$ for some $s_0 \in S$, and $\{s_0\} \in \mathscr{U}$. Thus, $\mathscr{U}$ is principal, and $h(\varphi) = \varphi(s_0)$ for every $\varphi \in k^S$, i.e., $h = \mathrm{pr}_{s_0}$.