Importance of complex functions in quantum mechanics In quantum mechanics, we work with the space $\mathcal{H} = L^2(\mathbb{R})$ of functions with complex value square integrable. Thus Hermitian operators will play a central role since they have a real mean, to which we can give a physical interpretation:
$$\overline{\langle A\rangle} = \overline{\langle x|Ax\rangle} = \langle Ax|x\rangle = \langle x|A^\dagger x\rangle  =  \langle x|A x\rangle  = \langle A\rangle$$
But I don't understand why we work with functions with complex values, it seems much more natural to me to work directly with real functions. Is it possible to study quantum mechanics with real-valued functions? What are the problems that will arise?
 A: As an example start with the 1D Schrödinger equation.
$$\left(-\frac{\hbar^2}{2m}\frac{\partial^2}{\partial x^2}+U(x)\right)\Psi(x,t)=-i\hbar\frac{\partial}{\partial t}\Psi(x,t)$$
We can expand $\Psi$ into its real and imaginary components by defining$\Psi(x,t)=R(x,t)+i I(x,t)$. The Schrödinger equation becomes
\begin{align}
\left\{
\begin{array}{l}\left(-\frac{\hbar^2}{2m}\frac{\partial^2}{\partial x^2}+U(x)\right)R(x,t)=\hbar\frac{\partial}{\partial t}I(x,t)\\ \left(-\frac{\hbar^2}{2m}\frac{\partial^2}{\partial x^2}+U(x)\right)I(x,t)\,=-\hbar\frac{\partial}{\partial t}R(x,t)\end{array}
\right.
\end{align}
So what have we gained? There are no more comple numbers which is nice but our single line Schrödinger equation has now become two coupled equations. This bulkier notation makes it harder to work with and/or solve the equation.
But still why would we want complex numbers in our equations when complex numbers aren't real? The historical dislike for complex numbers is still evident in the words real and imaginary component. We have never seen a complex number in real life. But I raise you the question: have a you ever seen a negative number in real life? Have you ever seen a real number? Have you ever seen something that needed infinite decimals to describe it? When negative numbers were first in use there was also a lot of backlash but they are still a useful tool.  It is believed that the first person to discover irrational numbers was drowned by the Pythagoreans because they disliked them that much. Still real numbers are indispensible in math. These 'weird' numbers are useful because some things are just better described using them.
So why are complex numbers especially suitable for quantum mechanics? Complex numbers are especially good at one thing: rotating. Solutions to wave equations become simple rotations using complex numbers. A rotation by $\theta$ can be expressed compactly as $e^{i\theta}$. The probability density in quantum mechanics depends only on the length of the wave function, not on its orientation. Using complex numbers this is denoted using $|\Psi|^2$ instead of $R^2+I^2$. This makes it also evident that the probability density function is invariant under a global phase rotation.
Still the real formulation of the Schrödinger equation is not entirely useless. In this paper they decompose the Schrödinger equation using $\Psi(x,t)=R(x,t)e^{iS(x,t)}$ and the resulting equations of motion allows them to compare QM and classical mechanics on equal footing.
A: Since the solutions to the time-dependent SE are of the form $\psi(x)e^{-iEt/\hbar}$ it is difficult to avoid complex wave functions.
Moreover a coherent state
$$
\vert \alpha\rangle=\sum_{n=0}^\infty e^{-\vert\alpha\vert^2/2}\frac{\alpha^n}{\sqrt{n!}}\vert n\rangle
$$
for instance is a complex combination of eigenfunctions of the harmonic oscillator whenever $\alpha\in \mathbb{C}$.  Even if you start with real $\alpha$, the state will evolve to a complex combination.
The probability densities of $(\psi_a(x)+\psi_b(x))/\sqrt{2}$ and $ (\psi_a(x)+i\psi_b(x))/\sqrt{2}$ are completely different (assuming the eigenfunctions are real).
Eigenstates of $\sigma_y$, describing a system with spin align along $\pm \hat y$ are complex combinations of the usual eigenstates of $\sigma_z$ describing systems with spin quantized along $\hat z$.
The list is long.  One cannot just do with reals without arbitrarily complicated and convoluted gymnastics.
A: Yes, standard quantum mechanics and quantum theory  can be formulated using only real numbers, by simply decomposing a complex number into its real and imaginary part. That is because complex numbers are nothing but the elements of $R^2$ equipped with a suitable notion of product. That is just mathematics and also trivial.
On the physical non-trivial  side, the question is why  are pure states unit vectors up to phases (i.e., up to real  rotations when decomposing complex numbers  into real and imaginary parts), instead of unit vectors up to signs?
The second possibility would denote a true real quantum theory.
I might mention that (only) a third possibility exists: quantum mechanics formulated with  the algebra of quaternions. No further possibility is allowed, at least as consequence of Soler's theorem, when assuming very basic postulates on the structure of the elementary ("yes-no") observables of a quantum theory, viewed as elements of an abstract orthomodular lattice.
The answers  are quite complex. As far as I am concerned, since I published several papers on the subject, an answer relies on the fact that the elementary constituents of the matter are intrinsically reletivistic. The existence of a representation of Poincaré group acting in the constituents described by (real/complex/quaternionic) von Neumann algebras of observables always permits to re-formulate every "true" real (in the above sense) quantum theory (or quaternionic quantum theory) into a standard complex fashion exploiting a complex structure naturally suggested by physics. However, there are several viewpoints on the subject.
Another important remark is that a true real quantum theory would not permit to state the celebrated  relation between dynamically conserved quantities and symmetries. From a certain perspective (starting from the real structure of Jordan algebra of observables)  the possibility to embody that interplay in the formalism  just  implies that the theory is intrinsically complex.
A: One often hears a statement that complex numbers are necessary for quantum theory (unless one just makes a trivial replacement of complex numbers with pairs of real numbers). Argumentation may be similar to that of @ZeroTheHero's answer's.
I believe, however, that this statement requires more sophisticated arguments. Let us consider, following Schrödinger (Nature, v.169, p.538 (1952)), a complex scalar solution $\psi$ of the Schrödinger (or Klein-Gordon) equation in electromagnetic potential $A^\mu$. Using a gauge transformation, we can always find (at least locally) a real solution $\varphi$ of the same equation, but in electromagnetic potential $B^\mu$, which equals $A^\mu$ up to a gradient of some function. Thus, $\psi$ and $A^\mu$ describe the same physical situation as $\varphi$ and $B^\mu$. Thus, one can do just with real wave functions in this case. Schrödinger offered the following comment: “That the wave function of [the Klein-Gordon equation] can be made real by a change of gauge is but a truism, though it contradicts the widespread belief about `charged’ fields requiring complex representation.”
A similar conclusion can be made for the Dirac equation in electromagnetic field (my article, published in J. Math. Phys.).
A: The electron wave function can be expressed as a 1D complex or a 2D real valued function of time and position. The choice for complex numbers is one of convenience. It avoids introducing 2D vector indices. Another convenience is that the algebra of $i$ is the same for the vector $$i=(0,1)$$ and the operator $$i= \begin{pmatrix} 0&-1\\1&0 \end{pmatrix}~.$$
In both cases $i^2 = -1$, which in the second is minus the 2D unit operator. This simplifies notation as in real notation distinction needs to be made between (2x2) operators and vectors.
This answer does not address the question why the electron wave function has this structure.
