I know that compact sets imply the existence of a maximizer, but is the converse true:
Let $(X,d)$ be a metric space. Suppose that whenever $f$ is a continuous (and real) function on $X$, there exists a point $y \in X$ such that $f(y) \geq f(x)$ for all $x \in X$. Then X is compact.