I assume that by compact, you mean quasi-compact (i.e. not necessarily Hausdorff but with the finite sucover property), otherwise any $Y$ with the coarsest topology would be a counterexample.

Then it seems that your notion is equivalent to pseudocompactness, namely that any continous $f:Y\to\mathbb{R}$ has compact image. I checked that quickly, so I may be wrong (I haven't found a reference in MR, although I would bet it is an exercise in Bourbaki).

The idea is first to observe that the property remains the same if you substitute $\mathbb{R}$ with $[0,1]\simeq[-\infty,\infty]$, basically because any one is included in the other (up to homeo).

Then since the graph of a continuous $f:Y\to\mathbb{R}$ is closed, $f(Y)$ must be closed in $\mathbb{R}$ and *also* $[-\infty,\infty]$, hence bounded. Similarly, any lower/upper semi-continuous $f$ is lower/upper bounded and attains its inf/sup.

For the converse, if $F$ is closed in $Y\times[0,1]$, but not its projection $F_2$, one may assume that $0$ isn't in $F_2$ but is in its closure. Then the function
$y\mapsto \inf  t : (y,t)\in F $ is lower semi-continuous and doesn't attain its infimum $0$.

By the way, pseudocompact doesn't imply (quasi-)compact, even for "nice" (completely regular) spaces, as is seen with the [long line][1] or simply the first uncountable ordinal
$\omega_1$ (with order topology).
There are also non-Hausdorff examples, see [wikipedia article][2].


  [1]: http://en.wikipedia.org/wiki/Long_line_%2528topology%2529
  [2]: http://en.wikipedia.org/wiki/Pseudocompact_space