Firstly, the claim is not correct for a general function $f: \mathbb{R} \to (0 , + \infty)$ where $\lim_{x \to \pm \infty} f(x) = 0$. For a counterexample, consider $f(x) = \begin{cases} 1/ |x| & x \neq 0 \\ 1 & x = 0\end{cases}$, which has no maximum despite satisfying the hypothesis. We must consider continuous functions. For the duration of this answer, we suppose $f$ is continuous, as well as satisfying the hypotheses you stated.-
Let $a = \max \{ f(x) : - 1 \leq x \leq 1 \} > 0 $, which exists by the extreme value theorem. If $\lim_{x \to \pm \infty} f(x) = 0$, then there exists $N \geq 0$ such that if $|x| > N$, then $0 \leq f(x) \leq a / 2$. Now, set $M = \max \{ f(x) : - N \leq x \leq N \}$, which also exists by the extreme value theorem. Since we suppose $N \geq 1$, it follows that $M \geq a$. Now, we note that $$\sup \{ f(x) : x \in \mathbb{R} \} = \max ( \sup \{ f(x) : - N \leq x \leq N \} , \sup \{ f(x) : |x| > N \}) = \max(M, \sup \{ f(x) : |x| > N \}) = M,$$ as $M \geq a \geq a / 2 \geq f(x)$ whenever $|x| > N$. But there exists $x \in [- N, N]$ such that $f(x) = M$, so $M = \sup \{ f(x) : x \in \mathbb{R} \}$ is in fact a maximum.