If $f$ has no infimum $> 0$, then $f^{-1}((\epsilon, \infty)) \ne M$ for any $\epsilon > 0$.
A very late edit:
After DrHal's comment brought my attention back to this, I realized it had never been completely answered. As noted in the comments, my answer above only shows that $M$ compact implies that all positive functions have a positive infimum. Daron's answer shows that all positive functions having a positive infimum implies that $M$ is complete. But it does not show that $M$ is totally bounded. So I would like to address this.
But first, there is a much simpler proof of completeness than Daron provides. Assume $(M, d)$ has the property that all positive functions have a positive infimum. Let $\{a_n\}_{n\in \Bbb N} \subseteq M$ be a Cauchy sequence. Assume that $\{a_n\}$ does not converge. Define $$f\ :\ M \to \Bbb R\ :\ x \mapsto \lim_n\ d(x, a_n)$$
Then $f$ is well-defined by the Cauchy condition and can easily be shown to be continuous and is clearly $\ge 0$. $f(x) = 0$ would imply $a_n \to x$, so $f$ must be positive. But by the Cauchy condition, $\lim_n f(a_n) = 0$, contradicting that $f$ has a positive infimum. Thus $\{a_n\}$ must converge.
To show that $M$ is totally bounded, another proof-by-contradiction can be used: if $M$ is not totally bounded, then there is an $\epsilon > 0$ such that $M$ is not covered by a finite number of balls of radius $2\epsilon$. Start with an arbitrary point $a_0$, then recursively choose $a_n$ to be at least $2\epsilon$ away for $a_k$ for all $k < n$. The sequence $\{a_n\}$ has the property that for all $x \in M$, there is at most one $n$ such that $d(x, a_n) < \epsilon$. Choose a continuous function $\varphi\ :\ \Bbb R \to [0, 1]$ such that $\varphi(0) = 1$ and $\varphi = 0$ outside of $(-\epsilon, \epsilon)$. Define $$h\ :\ M \to \Bbb R\ :\ x \to \sum_n\ n\ \varphi(d(x, a_n))$$
For any $x$, the sum has at most one non-zero entry, so it is finite and the continuity of $h$ follows from that of $\varphi$ and $d$. Obviously $h \ge 0$, and for all $n, h(a_n) = n$, so it is unbounded. This means that $$f\ :\ M \to \Bbb R\ :\ x \to \frac 1{1 + h(x)}$$
is positive and continuous, but has $0$ as its infimum. A contradiction.