First, note that $(e_i)_{i=1}^{2n}$ is the standard basis of $V$ while $(e^i)_{i=1}^{2n}$ is the associated dual basis and so it is a basis of $V^{*}$. Set
$$ \Omega = \begin{pmatrix} 0_n & I_n \\ -I_n & O_n. \end{pmatrix} $$
and verify that $\Omega$ is the matrix which represents the bilinear form $\beta$ with respect to the standard basis (that is, $\beta(e_i, e_j) = e_i^T \Omega e_j$).
Now, let
$$B = \begin{pmatrix} B_{1}^{1} & \dots & B_{n}^1 \\ \vdots & \ddots & \vdots \\ B^n_1 & \dots & B^n_n \end{pmatrix} \in M(2n,\mathbb{R}) $$
and let $f_B \colon V \rightarrow V$ be the linear map given by $f_B(v) = Bv$ (so that $f$ is represented by $B$ with respect to the standard basis). Note that we have $f_B(e_i) = B_i^j e_j$ and $f_B^{*} \colon V^{*} \rightarrow V^{*}$ is the dual map of $f_B$ which satisfies $f_B(e^i) = B^i_j e^j$.
Finally, let us tackle the question. A matrix $B \in M(2n,\mathbb{R})$ belongs to $\operatorname{Sp}(n,\mathbb{R})$ if and only if $B^T \Omega B = \Omega$. Multiplying on the left by $e_i^T$ and on the right by $e_j$, we see that
$$ \beta(e_i, e_j) = e_i^T \Omega e_j = e_i^T B^T \Omega B e_j = (B e_i)^T \Omega (B e_j) = \beta(B e_i, B e_j) = \beta(f_B(e_i), f_B(e_j)) $$
which shows that $B \in \operatorname{Sp}(n,\mathbb{R})$ if and only if $\beta(e_i,e_j) = \beta(f_B(e_i), f_B(e_j))$ for all $i,j$ (make sure you understand why!) and this is equivalent to $f_B^{*}(\beta) = \beta$.