This question is taken from Mukres' Topology (exercise 51.2.b). This site provides the following answer:
All “closed” segments of a path are homotopic to the whole path. Since $Y$ is path connected, for any two paths we can connect the final point of the first one with the initial point of the second one by a path to form the product of three paths, in which the two given paths are “closed” segments. Given the idea, it can be shown formally, of course.
Why does this prove that all paths in $Y$ are homotopic? For any two paths to be pasted to a new path in the same space does not prove that any two paths are homotopic, right?
My attempt at this problem is the following:
Take any two paths $f, f':[0,1] \rightarrow Y$, then $F(t,x) := (1-t)f(x) + tf'(x)$ is continuous and has $F(0,x) = f(x)$ and $F(1, x)=f'(x)$, thus $F$ is a homotopy between any two paths in $Y$ and thus all paths in $Y$ are homotopic.
However, I think that I am wrong since this doesn't use path-connectedness of $Y$.