When does a Möbius transformation map $\Im(z)>0$ to itself?
Möbius transformations map lines and circles to lines and circles. They are also continuous functions of the Riemann sphere. In some sense, lines are circles in the geometry of the Riemann sphere.
This information alone is enough to give a strong qualitative description of those Möbius transformations that map the upper half-plane to itself: they must map the real line (plus $\infty$) to itself, because that is the boundary of the upper half-plane.
Furthermore, it is orientation preserving; as you progress along the real line in the positive direction, the upper half-plane is on your left. This relationship is preserved by any Möbius transformation. So we require that the real line is not only mapped to itself, but it is mapped to itself in the same direction.
From the first observation, it should be straightforward to determine the coefficients are real. The second observation gives us the sign condition. (although depending on your knowledge, it might be easier to just look at the sign on the imaginary part of $f(i)$)
Hint:
$$ Im((az + b)(c\bar{z} + d)) = (ad - bc)Im(z) $$
Edit for more detail as requested:
Multiplying $f(z)$ by $\dfrac{c\bar{z} + d}{c\bar{z} + d}$, we are left with:
$$\dfrac{(az + b)(c \bar{z} + d)}{(cz + d)(c \bar{z} + d)} = \dfrac{(ac(z\bar{z}) + bd) + (bc \bar{z} + adz)}{(cz + d)\overline{(cz + d)}}$$
Now both $z \bar{z}$ and $z + \bar{z}$ are real, so the imaginary part of this expression is:
$$ Q = \dfrac{ad - bc}{(cz + d)\overline{(cz + d)}} Im(z) $$
Because $w \bar{w} \geq 0$ for all $w$, the sign of $\frac{Q}{Im(z)}$ must be the same as the sign of $ad - bc$. Therefore they have the same sign if $ad - bc > 0$
Second part of the question is that this map is onto, ie) every $z$ value has a preimage $w$, ie) $f(w) = z$
To see this is the case, imagine a vector in $\mathbb{C}^2$ as representing a ratio of two complex numbers. Then $\left( \begin{array}{c} z \\ 1 \end{array} \right)$ represents the ratio $\frac{z}{1}$. Then $f(z)$ is represented by the matrix equation:
$$ f \left( \begin{array}{c} z \\ 1 \end{array} \right) = \left( \begin{array}{cc} a & b \\ c & d \end{array} \right) \left( \begin{array}{c} z \\ 1 \end{array} \right)$$
or
$$ f = \left( \begin{array}{cc} a & b \\ c & d \end{array} \right) $$
Because the determinant $ad - bc > 0$ is non-zero, this map is invertible. This means that for any $ Z = \left( \begin{array}{c} z_1 \\ z_2 \end{array} \right)$, there is a $W = \left( \begin{array}{c} w_1 \\ w_2 \end{array} \right)$ such that $f(W) = Z$.
Dividing by $w_2$, we obtain the same ratio as before but with $W$ in the form that we know. If $w_2$ is $0$, then $z_2$ is $0$ so this will never be a problem.
Let $H_{+}=\{z\in \mathbb C: \Im (z)>0\}$ and let $H_{-}=\{z\in \mathbb C: \Im (z)<0\}$. Since $H_{+}$ is connected, therefore, $f(H_{+})$ is connected. Thus $f(H_{+})$ can not intersect both $H_{+}$ and $H_{-}$. Therefore, $f(H_{+})\subset H_{+}$ or $f(H_{+})\subset H_{-}$.
Since $f(i)=\dfrac{ai+b}{ci+d}=\dfrac{ac+bd+i(ad-bc)}{c^2+d^2} \in H_{+}$. Hence $f$ maps $H_{+}$ onto $H_{+}$