$f$ is monotonically increasing, $0 \le f \le 1$ and $\int_0^1 (f(x) - x) dx = 0$ then $\int_0^1|f(x)-x|dx \le \frac{1}{2}$.
Here we present a bit different, calculus-themed approach. In this answer, we will assume that $f : [0, 1] \to [0, 1]$ is monotone-increasing. We also write $I(f) = \int_{0}^{1} |f(x) - x| \, \mathrm{d}x$ for brevity.
Step 1 - Proof under extra assumptions. Assume further that $f$ is piecewise-smooth, $f(0) = 0$, and $f(1) = 1$. Then by the formula $\int |x|\,\mathrm{d}x=\frac{1}{2}x|x|+\mathsf{C}$, we have
$$ \int_{0}^{1} |f(x) - x|(f'(x)-1) \, \mathrm{d}x = \left[ \frac{1}{2}|f(x)-x|(f(x)-x) \right]_{0}^{1} = 0. $$
In particular,
$$I(f) = \frac{1}{2}\int_{0}^{1} |f(x) - x|(f'(x)+1) \, \mathrm{d}x.$$
Now pick $\alpha \in [0, 1]$ so that $f(\alpha) + \alpha = 1$. (This is possible since $x \mapsto f(x)+x$ increases from $0$ to $2$. Then by triangle inequality,
\begin{align*} \int_{0}^{\alpha} |f(x) - x|(f'(x)+1) \, \mathrm{d}x \leq \int_{0}^{\alpha} (f(x)+x)(f'(x)+1) \, \mathrm{d}x = \frac{1}{2}. \end{align*}
Similarly, by writing $|f(x)-x| = |(1-f(x))-(1-x)| \leq (1-f(x)) + (1-x)$, we get
\begin{align*} \int_{\alpha}^{1} |f(x) - x|(f'(x)+1) \, \mathrm{d}x \leq \int_{\alpha}^{1} (2-f(x)-x)(f'(x)+1) \, \mathrm{d}x = \frac{1}{2}. \end{align*}
Therefore $\int_{0}^{1} |f(x)-x| (f'(x)+1) \, \mathrm{d}x \leq 1$, which in turn implies $I(f) \leq \frac{1}{2}$ as required.
Remark. Let $\gamma(t) = (f(t)+t, f(t)-t)$. Then $\int_{0}^{1} |f(t)-t|(f'(t)+1)\,\mathrm{d}t = \int_{\gamma} |y|\,\mathrm{d}x$ computes the area between the path $\gamma$ and the horizontal axis. Note that $\gamma$ is essentially the $-45^\circ$-rotation of the graph $y = f(x)$ up to scaling.
Then the above bounds immediately follow from the fact that the graph of $\gamma$ defines a function on $[0, 2]$ which is squeezed between lines $y = \pm x$ and $y = \pm (2-x)$.
Step 2 - General case. For the general case, let $f_n$ be the linear interpolation of the points
$$(0, 0), \quad (\tfrac{1}{n},f(\tfrac{1}{n})), \quad \cdots, \quad (\tfrac{n-1}{n}, f(\tfrac{n-1}{n})), \quad (1, 1).$$
Then by monotonicity,
\begin{align*} |I(f_n) - I(f)| &\leq \int_{0}^{1} |f_n(x) - f(x)| \, \mathrm{d}x = \sum_{k=1}^{n} \int_{\frac{k-1}{n}}^{\frac{k}{n}} |f_n(x) - f(x)| \, \mathrm{d}x \\ &\leq \frac{1}{n}\left( [f(\tfrac{1}{n})-0] + \sum_{k=2}^{n-1} [f(\tfrac{k}{n}) - f(\tfrac{k-1}{n})] + [1-f(\tfrac{n-1}{n})] \right) \\ &= \frac{1}{n}, \end{align*}
hence $I(f_n) \to I(f)$ as $n\to\infty$ and the desired inequality $I(f) \leq \frac{1}{2}$ follows from the previous step.
In case you have some familiarity with measure theory:
Take an increasing sequence of simple functions $f_k \rightarrow f$ converging pointwise. By the monotone convergence theorem we have $\lim_{k \rightarrow \infty} \int_0^1 f_k(x) dx = \int_0^1 f(x) dx$. So it suffices to show the result for simple functions. The functions $f_k(x) - x$ will have only finitely many zeroes, so you know how to do this.