Let $f: S \to B$ the Serre-fibration and $\mathcal{F}$ a invertible sheaf on $S$.
The Serre cohomology spectral sequence provides the fact: $$H^p(B, R^qf_*\mathcal{F}) \Rightarrow H^{p+q}(S,\mathcal{F})$$
where $R^qf_*$ is the $q$-th derivative of direct image functor $f_*$ defined as sheafification of presheaf
$$U\mapsto H^{q}(f^{{-1}}(U),\mathcal{F})$$
for a sheaf $\mathcal{F}$.
My question is how does it imply that following formula holds:
$$\chi(\mathcal{F}) = \sum _q (-1)^q\chi(R^q f_*\mathcal{F})$$
Here $\chi(\mathcal{F})$ is the Euler characteristics defined via
$$\chi(\mathcal{F}) := \sum _{i \ge 0} (-1)^i \dim_k H^i(X, \mathcal{F})$$
My idea was using Five-term sequence and the additivity of Euler characteristics but I don't know how in can get iteratively higher derivatives $R^q f_*\mathcal{F}$ as in the given formula occuring on the RHS.
Futhermore using additivity of Euler characteristics I have to take into account that Five-term sequence gives rise for a extra cokernel which I can't handle.
It's worth noting that this doesn't really depend on the map being a Serre fibration or on invertibility of the sheaf. At the same time, it's somewhat cleaner to derive the equality you want using the derived category machinery instead of spectral sequences.
So let $f:X \to Y$ be a continuous map. This induces the right derived functor $Rf:D^+(X) \to D^+(Y)$, where I have written $D^+(X)$ for the bounded below derived category of sheaves (of abelian groups, or more generally modules over some fixed base ring $R$) on $X$. In order for the sum defining the Euler characteristic to be finite, we must assume that the map $f$ (and the constant maps $X,Y \to \{\mathrm{pt} \}$) is of finite homological dimension in the sense that it preserves the bounded derived category, $f_*:D^b(X) \to D^b(Y)$. But this is the only assumption we will need. The formula you want is then almost pure algebra (having to do with derived categories).
Now assume $R$ is a field and all the relevant cohomology groups are of finite dimension, so that the dimensions make sense. The Grothendieck group $K(D^b(X))$ is isomorphic to the Grothendieck group $K(\mathrm{Sh}(X))$ of the abelian category $\mathrm{Sh}(X)$ via the map $$[C] \mapsto \sum (-1)^j [H^j(C)], \ \hbox{for a complex $C$.}$$ In particular, the Euler characteristic $\chi(C)$ of a complex $C$ of sheaves is well-defined via transport of structure, equal to $$\chi(C)=\sum (-1)^j \chi(H^j(C)).$$
In case $X$ is a point, the Grothendieck group $K(\mathrm{Sh}(X))$ is isomorphic to $\mathbf{Z}$ via dimension, and composing with the previous map produces the Euler characteristic of the complex $C$ of vector spaces. We will write $\chi(C)$ for this, and, hoping it will not cause confusion, use the same symbol $\chi(F)$ for the Euler characteristic of a sheaf $F$ or a complex of sheaves.
Now writing $p_X:X \to \{\mathrm{pt} \}$ and $p_Y:Y \to \{\mathrm{pt} \}$ for the maps to a point we compute $$\chi(F)=\chi(R(p_X)_*(F))=\chi(R(p_Y)_* \circ Rf_* (F))=\chi(Rf_*(F)).$$ Thus $$\chi(F)=\sum (-1)^j \chi(H^j (Rf_*(F)))=\sum (-1)^j \chi(R^jf_*(F))$$ as claimed.