Proof: We begin with a lemma.
Lemma: Let $M$ and $N$ be smooth manifolds with $M$ compact and let $f:M\rightarrow N$ be an immersion. Then $f$ is an open map and is surjective.
Proof of Lemma: We first show that $f$ is an open map. Let $V\subset M$ be open and let $y\in f(V)$. Then $y=f(x)$ for some $x\in V$. Since $f$ is an immersion, $Df(x)$ is nonsingular. By the Inverse Function Theorem, $x$ has an open neighborhood $U\subset V$ such that $f(U)$ is open. Then $U\subset V\implies f(U)\subset f(V)$ is an open neighborhood of $y$. Since we can do this for any $y\in V$, $f(V)$ is open.
Now, $M$ is open in $M$, so $f(M)$ is open in $N$ by above. Since $M$ is compact, we know that $f(M)$ is compact and thus closed since $N$ is Hausdorff. This implies that $f(M)$ is clopen. Since the only clopen subsets of a connected space are the entire space or the empty set, and since $N$ is connected, it follows that $f(M)=N$. Thus $f$ is surjective. $\hspace{.25in}\blacksquare$
We now proceed with the proof of the main result. Since $M$ is compact, $f(M)$ is compact. By the lemma, any immersion $f:M\rightarrow \mathbb{R}^n$ is an open map and is surjective. Let $\{U_{\alpha}\}_{\alpha\in A}$ be an open covering of $\mathbb{R}^n$. Then $\{f^{-1}(U_{\alpha})\}_{\alpha\in A}$ is an open covering on $M$. Since $M$ is compact, it must have a finite subcover, say $\{f^{-1}(U_{\alpha_i})\}_{i=1}^n$. Since $f$ is surjective, $\{f(f^{-1}(U_{\alpha_i}))\}_{i=1}^n=\{U_{\alpha_i}\}_{i=1}^n$. This now implies that any open covering of $\mathbb{R}^n$ has a finite subcover, contradicting the non-compactness of $\mathbb{R}^n$. Therefore, there exists no immersion $f:M\rightarrow\mathbb{R}^n$. $\hspace{.25in}\blacksquare$