Spaces that invert weak homotopy equivalences.
The answer seems to be "no": only for contractible spaces Y (and Y=$\emptyset$) the functor [-,Y] inverts weak equivalences. As mentioned above I wrote an argument in https://arxiv.org/abs/1709.08734. It uses Jeff Strom and Tom Goodwillie's idea of considering a space whose path-components are the singletons. In this case its topology is similar to the cofinite topology.
Here is an interesting test case: let $B$ be the Stone-Cech compactification of a set $S$, let $A$ be the underlying set of $B$ with the discrete topology, and let $f$ be the identity map. Then $B$ is totally disconnected so every map from a simplex to $B$ is constant, and it follows that $f$ is a weak equivalence, so we must have $[B,Y]=[A,Y]=\text{Map}(A,\pi_0(Y))$. Note that $B$ is always compact and that if $S$ is large enough we can choose a surjective map $A\to Y$; it follows that there is a compact subset of $Y$ that meets every path component. I think it should be possible to extract a lot more from this line of argument, but I do not see it at the moment.