I have two questions regarding how two concepts that involve complex valued functions may come up in a natural way. (Non-natural ways are: These concept come up in order to present a unified theory, for the sake of generalization etc.; natural ways are: These is a specific problem that can only be solved if we use complex-valued functions, complex-valued functions help us to make arguments shorter etc.)
The first is the Lebesgue integral for complex-valued functions. The second is a complex Hilbert space (an example of which, to make a connection, are the $L_p$ spaces of complex-valued functions).
Remarks (except the first one, the EDIT, these are not essential for the above question, if you don't have the time to read them):
EDIT: Since a lot of answer essentially said "when building up our theory you just generalize [to complex-valued functions] because you can - and much later it will turn out that the generalization will have benefits" consider the following way of approaching how to learn a new mathematical theory.
You take the perspective of me inventing it, with the textbook being our oracle and giving you a constant stream of sudden insight. Since developing/inventing a theory takes hard work, you need a strong incentive to do so. Merely generalizing for the sake of it won't do! So for example suppose I had already developed complex analysis. (This itself is easily motivate-able, because after rigorously arriving at these mysterious complex numbers, which turned out to be useful to solve equations, you can ask yourself: Can you also do analysis with these new numbers ? And there you have the motivation for developing complex analysis.) But why go further ? At this point intrinsic mathematical interest is exhausted and unless a compelling reason is give, you wouldn't go further, e.g., generalize this again and again to the holomorphic function calculus (which is mentioned in one answer below).
Now I'm not saying you shouldn't generalize, I'm just saying that at this point I don't know the applications/reasons etc. that make that effort worthwhile - and finding these applications/reasons is precisely what I'm after. The easier it is to describe these motivations, the better. The also don't need to be historically accurate.
To give an example for the statement from the last sentence: Today no one would use as a first motivation for the concept of a group the fact that they arose as permutation of roots of equations of fifth order - as it was historically the case. Instead, today one simply notices some of the many examples of groups that come up in the most basic of mathematical constructions, such as $(\mathbb{R},+)$ and uses the prevalence of these structures as a motivation of distilling their common properties in the group axioms.For the (unsigned) Lebesgue integral for $[0,+\infty)$-valued functions there is an easy, natural way in which it comes up: The geometric question what kind of integral one gets if one substitutes the Jordan content of the "area under the graph" of the functions, which gives the Riemann integral, with the Lebesgue measure. Since the Lebesgue measure - and more generally, the question of what it means to measure something - itself also enjoys nice geometric descriptions, so this entire approach is a natural line of questions.
(With a bit of a stretch one may also say the Lebesgue integral for $\overline{ \mathbb{R}}$-valued functions (which have to absolutely integrable) comes up naturally. But I can't see any natural motivation that allows the further generalization of the Lebesgue integral to $\mathbb{C}$-valued functions.)For Hilbert spaces I beg you not to mention the complex-valued Hilbert spaces which come up in quantum mechanics: I understand nothing of theoretical physics so using this as a motivation won't help me (and if this is the only motivation, I'd be disappointed of the concession mathematics makes to physics by inventing a whole class of spaces just for them). Other than that I don't know of any complex Hilbert space that arise naturally. If one wants to solve PDEs, apparently the main application of Hilbert spaces, it seems that all relevant Hilbert spaces are real. The properties of complex Hilbert spaces can readily be abstract from concrete spaces (like the $L_p$ spaces for complex-valued Hilbert spaces), but a natural way in which they come up is unknown to me.