I've seen the following nice proof credited to Paul Halmos. Assume that $A$ is not invertible. By performing row and column operations on $A$ and encoding them with invertible matrices, we can write
$$ A = P \begin{pmatrix} I_{r \times r} & 0 \\ 0 & 0 \end{pmatrix} Q $$
where $P, Q$ are invertible and $r = \mathrm{rank}(A)$. Write also
$$ QBP = \begin{pmatrix} B_{11} & B_{12} \\ B_{21} & B_{22} \end{pmatrix} $$
where $B_{11} \in M_{r}(\mathbb{F}), B_{22} \in M_{(n-r)\times(n-r)}(\mathbb{F})$, etc.
Then we have
$$ AB = P \begin{pmatrix} I_{r \times r} & 0 \\ 0 & 0 \end{pmatrix} Q Q^{-1} \begin{pmatrix} B_{11} & B_{12} \\ B_{21} & B_{22} \end{pmatrix} P^{-1} = P \begin{pmatrix} I_{r \times r} & 0 \\ 0 & 0 \end{pmatrix}\begin{pmatrix} B_{11} & B_{12} \\ B_{21} & B_{22} \end{pmatrix}P^{-1} = P \begin{pmatrix} B_{11} & B_{12} \\ 0 & 0 \end{pmatrix} P^{-1}. $$
This shows that $AB$ is similar to a block upper triangular matrix and so $\chi_{AB}(\lambda) = \lambda^{n-r} \chi_{B_{11}}(\lambda)$ (where $\chi$ is the characteristic polynomial).
Similarly,
$$ BA = Q^{-1} \begin{pmatrix} B_{11} & B_{12} \\ B_{21} & B_{22} \end{pmatrix} P^{-1} P \begin{pmatrix} I_{r \times r} & 0 \\ 0 & 0 \end{pmatrix} Q = Q^{-1} \begin{pmatrix} B_{11} & B_{12} \\ B_{21} & B_{22} \end{pmatrix} \begin{pmatrix} I_{r \times r} & 0 \\ 0 & 0 \end{pmatrix} Q = Q^{-1} \begin{pmatrix} B_{11} & 0 \\ B_{21} & 0 \end{pmatrix} Q $$
which shows that $BA$ is similar to a block lower triangular matrix and so $\chi_{BA}(\lambda) = \lambda^{n-r} \chi_{B_{11}}(\lambda)$.
We have shown that $\chi_{AB}(\lambda) = \chi_{BA}(\lambda)$ which shows that the eigenvalues of $AB$ and $BA$ (and even their algebraic multiplicity) coincide.