Since the metric and inverse metric are related by
$$
g^{\mu\lambda}g_{\lambda\nu} = \delta^\mu_\nu
$$
taking the variation of both sides gives
$$
\delta g^{\mu\lambda}g_{\lambda\nu} + g^{\mu\lambda}\delta g_{\lambda\nu} =0
$$
or in other words
$$
\delta g_{\mu\nu} = -g_{\mu\rho}g_{\nu\sigma}\delta g^{\rho\sigma}
$$
It follows that there is a one-to-one correspondence between variations in the metric and its inverse, so that a functional of the metric is stationary with respect to variations of the metric if and only if a functional of the metric is stationary with respect to its inverse. Noting this fact, we see that we can choose to perform either variations with respect to the metric or its inverse depending on which is more convenient.
For example, the Eisntein-Hilbert action involves the Ricci scalar which can be written in terms of the inverse metric as $R = g^{\mu\nu}R_{\mu\nu}$, so varying with respect to the inverse metric becomes convenient; $\delta R = \delta g^{\mu\nu} R_{\mu\nu} + g^{\mu\nu}\delta R_{\mu\nu}$.