Can we relate $H^i(Y,\mathscr{G})$ and $H^i(X,f^*\mathscr{G})$ when $f:X\to Y$ is a morphism of schemes? Let $f:X\to Y$ be a morphism of schemes. If $\mathscr{F}$ is a sheaf over $X$ then I know that
$$H^i(X,\mathscr{F})\cong H^i(Y,f_*\mathscr{F})\qquad\text{for all}\quad i\geq 0$$
whenever $j$ is a closed immersion or $\mathscr{F}$ is quasi-coherent and $f$ is an affine morphism between noetherian separated schemes.
I wonder if there's some similar relation for the inverse image.
 A: Question: "I wonder if there's some similar relation for the inverse image."
Answer: Let $Y:=Spec(A)$ be a noetherian affine scheme and let $\mathcal{E}$ be an $\mathcal{O}_Y$-module. The isomorphism you write down above holds for any affine morphism of noetherian separated schemes and $\mathcal{F}$ quasi coherent.
Let us assume there is an isomorphism
$$ H^i(X, f^*\mathcal{E})\cong H^i(Y, \mathcal{E}).$$
The right hand since is zero for $i\geq 1$ since $Y$ is affine (Hartshorne III.3.5).
It seems the left hand side is not zero in general, but I do not  have an immediate example. If $E$ is a non-trivial finite rank projective $A$-module, it follows $f^*\mathcal{E}$ will be a non-trivial locally free sheaf on $X$ and this should have non-zero cohomology groups in general if $X$ is non-affine.
Example: If $X:=Spec(B)$ there is a canonical map
$$ \rho: H^0(Y, \mathcal{E}) \cong E \rightarrow E\otimes_A B\cong H^0(X, f^*\mathcal{E})$$
defined by
$$\rho(e):=e\otimes 1$$
and the map $\rho$ is seldom an isomorphism (even when $f$ is flat).
Example: Let $A:=k$ a field and $dim(B) \geq 1$.
It follows $B\cong \oplus_{i \in I}ke_i$ with $\# I=\infty$
$$E\otimes_A B\cong \oplus_{i\in I} Ee_i \neq E.$$
The map $f$ is flat since $B$ is a flat $A$-algebra. Hence the map $\rho$ is never an isomorphism for $X$ affine of positive dimension over a field $k$.
Example: If $B:=A/I$ we get a canonical map
$$\rho: E \rightarrow B\otimes_A E\cong E/IE=E$$
since $IE=(0)$. Hence when $f$ is a closed immersion the map $\rho$ is always an isomorphism.
