Why does integral and the imaginary part commute?

You can always write $f = \operatorname{Re}(f)+i\operatorname{Im}(f)$. Then, by linearity $\int f = \int \operatorname{Re}(f)+i\int \operatorname{Im}(f)$. But this is clearly the unique decomposition of $\int f$ in its real and imaginary part since both $\int \operatorname{Re}(f)$ and $\int \operatorname{Im}(f)$ are real numbers, hence we must have $\operatorname{Re}\int f = \int \operatorname{Re}f$ and the same for the imaginary part.

This is by the way a special case of the following more general observation:

If $E,F$ are complex Banach lattices and $T:E\to F$ is a real operator, i.e. mapping real elements to real elements, then $T\circ \operatorname{Re} = \operatorname{Re}\circ T$. Positive Operators are a special case of real operators and your question is a special case if we set $E = L^1, F=\mathbb C, T=\int$.