There exist several functional calculi. Selfadjointness is not a requirement.
For instance, the Riesz-Dunford calculus
$$
f(A) = \frac{1}{2\pi i} \oint_{\partial \sigma(A)} f(\lambda) (\lambda - A)^{-1} d\lambda
$$
works for arbitrary continuous operators in a complex Banach space. The integration path is any simple counterclockwise Jordan curve in $\mathbb{C}$ which surround the spectrum $\sigma(A)$. This calculus is basically an extension of Cauchy's formula from Complex Analysis, $f(z) = \frac{1}{2\pi i} \oint \frac{f(\zeta)}{\zeta - z} d\zeta$, from numbers to operators.
The calculus for selfadjoint operators allows for an extension to densely defined unbounded (discontinuous) selfadjoint operators. It has a counterpart for normal operators by decomposing a normal operator A into its real part $(A+A^*)/2$ and its imaginary part $(A-A^*)/(2i)$.
Why selfadjoint operators?
The main reason is historical. At first, there wasn't a spectral decomposition of linear operators (in fact, Stefan Banach became active after WWI, whereas Hilbert was already active in the decades before Banach!), but a decomposition of hermitian (or symmetric) quadratic forms, analogous to the principal axis transform, and mainly for what we would call today a selfadjoint compact operator (or its "inverse").
Often, the method was even just for "infinite Hermitian matrices", where one restricted first to $n$-dimensional subspaces and $n \times n$-matrices, and then took a limit $n\to \infty$ for the corresponding quadratic form. "Completely continuous" operators then came out naturally. But besides the classical eigenvalues, a "continuous spectrum" occurred in the infinite dimensional case and this was new and required new methods for its treatment.
One can extend spectral calculus to $C^*$-algebras and to some generalizations of them. Moreover,
$H^\infty$-calculus extends even in a completely different direction by starting with unitary operators and then extending to contractions.
But again: Why selfadjoint operators? Because they have a real spectrum, and one usually starts mathematics with real numbers and not with complex ones. :-) The spectral calculus for selfadjoint operators also had connections to solving moment problems, in particular the Hamburger moment problem, and this was important for probability, systems analysis, statistics or mechanics.
Moreover, many (stationary) problems from physics are associated to selfadjoint forms, e.g. complex extensions of a kinetic energy form, or the Dirichlet form for the Laplacian operator in potential theory.
These quadratic forms allow for a variational formulation, and this was even one of the historical origins for spectral theory, namely via Lagrange multipliers $\lambda$ by introducing elements of unit norm via a side condition. Studying the Dirichlet problem for the Laplacian was one of the main topics in 19th century analysis.
I'd recommend to you to read something about the history of functional analysis.
(If you understand German or can use an online translation - e.g. google translate for pictures or .pdf -, then I'd recommend the book "Heuser, Harro: Funktionalanalysis" in its last German edition. It has an emphatic appendix about the emergence of functional analysis, but this appendix has never been translated into English, and the former editions even don't have that appendix!)
In David Hilbert's papers, you'll most often read about quadratic forms and their spectra.