[First proof of smooth base change] This proof is very long but more direct (using less general theory) than the second proof given below. \medskip\noindent The theorem is local on $X_\etale$. More precisely, suppose we have $U \to X$ \'etale such that $U \to S$ factors as $U \to V \to S$ with $V \to S$ \'etale. Then we can consider the cartesian square $$ \xymatrix{ U \ar[d]_{f'} & U \times_X Y \ar[l]^{h'} \ar[d]^{e'} \\ V & V \times_S T \ar[l]_{g'} } $$ and setting $\mathcal{F}' = \mathcal{F}|_{V \times_S T}$ we have $f^{-1}R^qg_*\mathcal{F}|_U = (f')^{-1}R^qg'_*\mathcal{F}'$ and $R^qh_*e^{-1}\mathcal{F}|_U = R^qh'_*(e')^{-1}\mathcal{F}'$ (as follows from the compatibility of localization with morphisms of sites, see Sites, Lemma \ref{sites-lemma-localize-morphism-strong} and and Cohomology on Sites, Lemma \ref{sites-cohomology-lemma-restrict-direct-image-open}). Thus it suffices to produce an \'etale covering of $X$ by $U \to X$ and factorizations $U \to V \to S$ as above such that the theorem holds for the diagram with $f'$, $h'$, $g'$, $e'$. \medskip\noindent By the local structure of smooth morphisms, see Morphisms, Lemma \ref{morphisms-lemma-smooth-etale-over-affine-space}, we may assume $X$ and $S$ are affine and $X \to S$ factors through an \'etale morphism $X \to \mathbf{A}^d_S$. If we have a tower of cartesian diagrams $$ \xymatrix{ W \ar[d]_i & Z \ar[l]^j \ar[d]^k \\ X \ar[d]_f & Y \ar[l]^h \ar[d]^e \\ S & T \ar[l]_g } $$ and the theorem holds for the bottom and top squares, then the theorem holds for the outer rectangle; this is formal. Writing $X \to S$ as the composition $$ X \to \mathbf{A}^{d - 1}_S \to \mathbf{A}^{d - 2}_S \to \ldots \to \mathbf{A}^1_S \to S $$ we conclude that it suffices to prove the theorem when $X$ and $S$ are affine and $X \to S$ has relative dimension $1$. \medskip\noindent For every $n \geq 1$ invertible on $S$, let $\mathcal{F}[n]$ be the subsheaf of sections of $\mathcal{F}$ annihilated by $n$. Then $\mathcal{F} = \colim \mathcal{F}[n]$ by our assumption on the stalks of $\mathcal{F}$. The functors $e^{-1}$ and $f^{-1}$ commute with colimits as they are left adjoints. The functors $R^qh_*$ and $R^qg_*$ commute with filtered colimits by Lemma \ref{lemma-relative-colimit}. Thus it suffices to prove the theorem for $\mathcal{F}[n]$. From now on we fix an integer $n$, we work with sheaves of $\mathbf{Z}/n\mathbf{Z}$-modules and we assume $S$ is a scheme over $\Spec(\mathbf{Z}[1/n])$. \medskip\noindent Next, we reduce to the case where $T$ is affine. Since $g$ is quasi-compact and quasi-separate and $S$ is affine, the scheme $T$ is quasi-compact and quasi-separated. Thus we can use the induction principle of Cohomology of Schemes, Lemma \ref{coherent-lemma-induction-principle}. Hence it suffices to that if $T = W \cup W'$ is an open covering and the theorem holds for the squares $$ \xymatrix{ X \ar[d] & e^{-1}(W) \ar[l]^i \ar[d] \\ S & W \ar[l]_a } \quad \xymatrix{ X \ar[d] & e^{-1}(W') \ar[l]^j \ar[d] \\ S & W' \ar[l]_b } \quad \xymatrix{ X \ar[d] & e^{-1}(W \cap W') \ar[l]^-k \ar[d] \\ S & W \cap W' \ar[l]_c } $$ then the theorem holds for the original diagram. To see this we consider the diagram $$ \xymatrix{ f^{-1}R^{q - 1}c_*\mathcal{F}|_{W \cap W'} \ar[d]_{\cong} \ar[r] & f^{-1}R^qg_*\mathcal{F} \ar[d] \ar[r] & f^{-1}R^qa_*\mathcal{F}|_W \ar[d] \oplus f^{-1}R^qb_*\mathcal{F}|_{W'} \ar[d]_{\cong} \\ R^qk_*e^{-1}\mathcal{F}|_{e^{-1}(W \cap W')} \ar[r] & R^qh_*e^{-1}\mathcal{F} \ar[r] & R^qi_*e^{-1}\mathcal{F}|_{e^{-1}(W)} \oplus R^qj_*e^{-1}\mathcal{F}|_{e^{-1}(W')} } $$ whose rows are the long exact sequences of Lemma \ref{lemma-relative-mayer-vietoris}. Thus the $5$-lemma gives the desired conclusion. \medskip\noindent Summarizing, we may assume $S$, $X$, $T$, and $Y$ affine, $\mathcal{F}$ is $n$ torsion, $X \to S$ is smooth of relative dimension $1$, and $S$ is a scheme over $\mathbf{Z}[1/n]$. We will prove the theorem by induction on $q$. The base case $q = 0$ is handled by Lemma \ref{lemma-fppf-reduced-fibres-base-change-f-star}. Assume $q > 0$ and the theorem holds for all smaller degrees. Choose a short exact sequence $0 \to \mathcal{F} \to \mathcal{I} \to \mathcal{Q} \to 0$ where $\mathcal{I}$ is an injective sheaf of $\mathbf{Z}/n\mathbf{Z}$-modules. Consider the induced diagram $$ \xymatrix{ f^{-1}R^{q - 1}g_*\mathcal{I} \ar[d]_{\cong} \ar[r] & f^{-1}R^{q - 1}g_*\mathcal{Q} \ar[d]_{\cong} \ar[r] & f^{-1}R^qg_*\mathcal{F} \ar[d] \ar[r] & 0 \ar[d] \\ R^{q - 1}h_*e^{-1}\mathcal{I} \ar[r] & R^{q - 1}h_*e^{-1}\mathcal{Q} \ar[r] & R^qh_*e^{-1}\mathcal{F} \ar[r] & R^qh_*e^{-1}\mathcal{I} } $$ with exact rows. We have the zero in the right upper corner as $\mathcal{I}$ is injective. The left two vertical arrows are isomorphisms by induction hypothesis. Thus it suffices to prove that $R^qh_*e^{-1}\mathcal{I} = 0$. \medskip\noindent Write $S = \Spec(A)$ and $T = \Spec(B)$ and say the morphism $T \to S$ is given by the ring map $A \to B$. We can write $A \to B = \colim_{i \in I} (A_i \to B_i)$ as a filtered colimit of maps of rings of finite type over $\mathbf{Z}[1/n]$ (see Algebra, Lemma \ref{algebra-lemma-limit-no-condition}). For $i \in I$ we set $S_i = \Spec(A_i)$ and $T_i = \Spec(B_i)$. For $i$ large enough we can find a smooth morphism $X_i \to S_i$ of relative dimension $1$ such that $X = X_i \times_{S_i} S$, see Limits, Lemmas \ref{limits-lemma-descend-finite-presentation}, \ref{limits-lemma-descend-smooth}, and \ref{limits-lemma-descend-dimension-d}. Set $Y_i = X_i \times_{S_i} T_i$ to get squares $$ \xymatrix{ X_i \ar[d]_{f_i} & Y_i \ar[l]^{h_i} \ar[d]^{e_i} \\ S_i & T_i \ar[l]_{g_i} } $$ Observe that $\mathcal{I}_i = (T \to T_i)_*\mathcal{I}$ is an injective sheaf of $\mathbf{Z}/n\mathbf{Z}$-modules on $T_i$, see Cohomology on Sites, Lemma \ref{sites-cohomology-lemma-pushforward-injective-flat}. We have $\mathcal{I} = \colim (T \to T_i)^{-1}\mathcal{I}_i$ by Lemma \ref{lemma-linus-hamann}. Pulling back by $e$ we get $e^{-1}\mathcal{I} = \colim (Y \to Y_i)^{-1}e_i^{-1}\mathcal{I}_i$. By Lemma \ref{lemma-relative-colimit-general} applied to the system of morphisms $Y_i \to X_i$ with limit $Y \to X$ we have $$ R^qh_*e^{-1}\mathcal{I} = \colim (X \to X_i)^{-1} R^qh_{i, *} e_i^{-1}\mathcal{I}_i $$ This reduces us to the case where $T$ and $S$ are affine of finite type over $\mathbf{Z}[1/n]$. \medskip\noindent Summarizing, we have an integer $q \geq 1$ such that the theorem holds in degrees $< q$, the schemes $S$ and $T$ affine of finite type type over $\mathbf{Z}[1/n]$, we have $X \to S$ smooth of relative dimension $1$ with $X$ affine, and $\mathcal{I}$ is an injective sheaf of $\mathbf{Z}/n\mathbf{Z}$-modules and we have to show that $R^qh_*e^{-1}\mathcal{I} = 0$. We will do this by induction on $\dim(T)$. \medskip\noindent The base case is $T = \emptyset$, i.e., $\dim(T) < 0$. If you don't like this, you can take as your base case the case $\dim(T) = 0$. In this case $T \to S$ is finite (in fact even $T \to \Spec(\mathbf{Z}[1/n])$ is finite as the target is Jacobson; details omitted), so $h$ is finite too and hence has vanishing higher direct images (see references below). \medskip\noindent Assume $\dim(T) = d \geq 0$ and we know the result for all situations where $T$ has lower dimension. Pick $U$ affine and \'etale over $X$ and a section $\xi$ of $R^qh_*q^{-1}\mathcal{I}$ over $U$. We have to show that $\xi$ is zero. Of course, we may replace $X$ by $U$ (and correspondingly $Y$ by $U \times_X Y$) and assume $\xi \in H^0(X, R^qh_*e^{-1}\mathcal{I})$. Moreover, since $R^qh_*e^{-1}\mathcal{I}$ is a sheaf, it suffices to prove that $\xi$ is zero locally on $X$. Hence we may replace $X$ by the members of an \'etale covering. In particular, using Lemma \ref{lemma-higher-direct-images} we may assume that $\xi$ is the image of an element $\tilde \xi \in H^q(Y, e^{-1}\mathcal{I})$. In terms of $\tilde \xi$ our task is to show that $\tilde \xi$ dies in $H^q(U_i \times_X Y, e^{-1}\mathcal{I})$ for some \'etale covering $\{U_i \to X\}$. \medskip\noindent By More on Morphisms, Lemma \ref{more-morphisms-lemma-cover-smooth-by-special} we may assume that $X \to S$ factors as $X \to V \to S$ where $V \to S$ is \'etale and $X \to V$ is a smooth morphism of affine schemes of relative dimension $1$, has a section, and has geometrically connected fibres. Observe that $\dim(V \times_S T) \leq \dim(T) = d$ for example by More on Algebra, Lemma \ref{more-algebra-lemma-dimension-etale-extension}. Hence we may then replace $S$ by $V$ and $T$ by $V \times_S T$ (exactly as in the discussion in the first paragraph of the proof). Thus we may assume $X \to S$ is smooth of relative dimension $1$, geometrically connected fibres, and has a section $\sigma : S \to X$. \medskip\noindent Let $\pi : T' \to T$ be a finite surjective morphism. We will use below that $\dim(T') \leq \dim(T) = d$, see Algebra, Lemma \ref{algebra-lemma-integral-dim-up}. Choose an injective map $\pi^{-1}\mathcal{I} \to \mathcal{I}'$ into an injective sheaf of $\mathbf{Z}/n\mathbf{Z}$-modules. Then $\mathcal{I} \to \pi_*\mathcal{I}'$ is injective and hence has a splitting (as $\mathcal{I}$ is an injective sheaf of $\mathbf{Z}/n\mathbf{Z}$-modules). Denote $\pi' : Y' = Y \times_T T' \to Y$ the base change of $\pi$ and $e' : Y' \to T'$ the base change of $e$. Picture $$ \xymatrix{ X \ar[d]_f & Y \ar[l]^h \ar[d]^e & Y' \ar[l]^{\pi'} \ar[d]^{e'} \\ S & T \ar[l]_g & T' \ar[l]_\pi } $$ By Proposition \ref{proposition-finite-higher-direct-image-zero} and Lemma \ref{lemma-finite-pushforward-commutes-with-base-change} we have $R\pi'_*(e')^{-1}\mathcal{I}' = e^{-1}\pi_*\mathcal{I}'$. Thus by the Leray spectral sequence (Cohomology on Sites, Lemma \ref{sites-cohomology-lemma-Leray}) we have $$ H^q(Y', (e')^{-1}\mathcal{I}') = H^q(Y, e^{-1}\pi_*\mathcal{I}') \supset H^q(Y, e^{-1}\mathcal{I}) $$ and this remains true after base change by any $U \to X$ \'etale. Thus we may replace $T$ by $T'$, $\mathcal{I}$ by $\mathcal{I}'$ and $\tilde \xi$ by its image in $H^q(Y', (e')^{-1}\mathcal{I}')$. \medskip\noindent Suppose we have a factorization $T \to S' \to S$ where $\pi : S' \to S$ is finite. Setting $X' = S' \times_S X$ we can consider the induced diagram $$ \xymatrix{ X \ar[d]_f & X' \ar[l]^{\pi'} \ar[d]^{f'} & Y \ar[l]^{h'} \ar[d]^e \\ S & S' \ar[l]_\pi & T \ar[l]_g } $$ Since $\pi'$ has vanishing higher direct images we see that $R^qh_*e^{-1}\mathcal{I} = \pi'_*R^qh'_*e^{-1}\mathcal{I}$ by the Leray spectral sequence. Hence $H^0(X, R^qh_*e^{-1}\mathcal{I}) = H^0(X', R^qh'_*e^{-1}\mathcal{I})$. Thus $\xi$ is zero if and only if the corresponding section of $R^qh'_*e^{-1}\mathcal{I}$ is zero\footnote{This step can also be seen another way. Namely, we have to show that there is an \'etale covering $\{U_i \to X\}$ such that $\tilde \xi$ dies in $H^q(U_i \times_X Y, e^{-1}\mathcal{I})$. However, if we prove there is an \'etale covering $\{U'_j \to X'\}$ such that $\tilde \xi$ dies in $H^q(U'_i \times_{X'} Y, e^{-1}\mathcal{I})$, then by property (B) for $X' \to X$ (Lemma \ref{lemma-finite-B}) there exists an \'etale covering $\{U_i \to X\}$ such that $U_i \times_X X'$ is a disjoint union of schemes over $X'$ each of which factors through $U'_j$ for some $j$. Thus we see that $\tilde \xi$ dies in $H^q(U_i \times_X Y, e^{-1}\mathcal{I})$ as desired.}. Thus we may replace $S$ by $S'$ and $X$ by $X'$. Observe that $\sigma : S \to X$ base changes to $\sigma' : S' \to X'$ and hence after this replacement it is still true that $X \to S$ has a section $\sigma$ and geometrically connected fibres. \medskip\noindent We will use that $S$ and $T$ are Nagata schemes, see Algebra, Proposition \ref{algebra-proposition-ubiquity-nagata} which will guarantee that various normalizations are finite, see Morphisms, Lemmas \ref{morphisms-lemma-nagata-normalization-finite} and \ref{morphisms-lemma-nagata-normalization}. In particular, we may first replace $T$ by its normalization and then replace $S$ by the normalization of $S$ in $T$. Then $T \to S$ is a disjoint union of dominant morphisms of integral normal schemes, see Morphisms, Lemma \ref{morphisms-lemma-normal-normalization}. Clearly we may argue one connnected component at a time, hence we may assume $T \to S$ is a dominant morphism of integral normal schemes. \medskip\noindent Let $s \in S$ and $t \in T$ be the generic points. By Lemma \ref{lemma-smooth-base-change-fields} there exist finite field extensions $K/\kappa(t)$ and $k/\kappa(s)$ such that $k$ is contained in $K$ and a finite \'etale Galois covering $Z \to X_k$ with Galois group $G$ of order dividing a power of $n$ split over $\sigma(\Spec(k))$ such that $\tilde \xi$ maps to zero in $H^q(Z_K, e^{-1}\mathcal{I}|_{Z_K})$. Let $T' \to T$ be the normalization of $T$ in $\Spec(K)$ and let $S' \to S$ be the normalization of $S$ in $\Spec(k)$. Then we obtain a commutative diagram $$ \xymatrix{ S' \ar[d] & T' \ar[l] \ar[d] \\ S & T \ar[l] } $$ whose vertical arrows are finite. By the arguments given above we may and do replace $S$ and $T$ by $S'$ and $T'$ (and correspondingly $X$ by $X \times_S S'$ and $Y$ by $Y \times_T T'$). After this replacement we conclude we have a finite \'etale Galois covering $Z \to X_s$ of the generic fibre of $X \to S$ with Galois group $G$ of order dividing a power of $n$ split over $\sigma(s)$ such that $\tilde \xi$ maps to zero in $H^q(Z_t, (Z_t \to Y)^{-1}e^{-1}\mathcal{I})$. Here $Z_t = Z \times_S t = Z \times_s t = Z \times_{X_s} Y_t$. Since $n$ is invertible on $S$, by Fundamental Groups, Lemma \ref{pione-lemma-extend-covering} we can find a finite \'etale morphism $U \to X$ whose restriction to $X_s$ is $Z$. \medskip\noindent At this point we replace $X$ by $U$ and $Y$ by $U \times_X Y$. After this replacement it may no longer be the case that the fibres of $X \to S$ are geometrically connected (there still is a section but we won't use this), but what we gain is that after this replacement $\tilde \xi$ maps to zero in $H^q(Y_t, e^{-1}\mathcal{I})$, i.e., $\tilde \xi$ restricts to zero on the generic fibre of $Y \to T$. \medskip\noindent Recall that $t$ is the spectrum of the function field of $T$, i.e., as a scheme $t$ is the limit of the nonempty affine open subschemes of $T$. By Lemma \ref{lemma-directed-colimit-cohomology} we conclude there exists a nonempty open subscheme $V \subset T$ such that $\tilde \xi$ maps to zero in $H^q(Y \times_T V, e^{-1}\mathcal{I}|_{Y \times_T V})$. \medskip\noindent Denote $Z = T \setminus V$. Consider the diagram $$ \xymatrix{ Y \times_T Z \ar[d]_{e_Z} \ar[r]_{i'} & Y \ar[d]_e & Y \times_T V \ar[l]^{j'} \ar[d]^{e_V} \\ Z \ar[r]^i & T & V \ar[l]_j } $$ Choose an injection $i^{-1}\mathcal{I} \to \mathcal{I}'$ into an injective sheaf of $\mathbf{Z}/n\mathbf{Z}$-modules on $Z$. Looking at stalks we see that the map $$ \mathcal{I} \to j_*\mathcal{I}|_V \oplus i_*\mathcal{I}' $$ is injective and hence splits as $\mathcal{I}$ is an injective sheaf of $\mathbf{Z}/n\mathbf{Z}$-modules. Thus it suffices to show that $\tilde \xi$ maps to zero in $$ H^q(Y, e^{-1}j_*\mathcal{I}|_V) \oplus H^q(Y, e^{-1}i_*\mathcal{I}') $$ at least after replacing $X$ by the members of an \'etale covering. Observe that $$ e^{-1}j_*\mathcal{I}|_V = j'_*e_V^{-1}\mathcal{I}|_V,\quad e^{-1}i_*\mathcal{I}' = i'_*e_Z^{-1}\mathcal{I}' $$ By induction hypothesis on $q$ we see that $$ R^aj'_*e_V^{-1}\mathcal{I}|_V = 0, \quad a = 1, \ldots, q - 1 $$ By the Leray spectral sequence for $j'$ and the vanishing above it follows that $$ H^q(Y, j'_*(e_V^{-1}\mathcal{I}|_V)) \longrightarrow H^q(Y \times_T V, e_V^{-1}\mathcal{I}_V) = H^q(Y \times_T V, e^{-1}\mathcal{I}|_{Y \times_T V}) $$ is injective. Thus the vanishing of the image of $\tilde \xi$ in the first summand above because we know $\tilde \xi$ vanishes in $H^q(Y \times_T V, e^{-1}\mathcal{I}|_{Y \times_T V})$. Since $\dim(Z) < \dim(T) = d$ by induction the image of $\tilde \xi$ in the second summand $$ H^q(Y, e^{-1}i_*\mathcal{I}') = H^q(Y, i'_*e_Z^{-1}\mathcal{I}') = H^q(Y \times_T Z, e_Z^{-1}\mathcal{I}') $$ dies after replacing $X$ by the members of a suitable \'etale covering. This finishes the proof of the smooth base change theorem.