The expectation value of an observable is the average value of its outcome weighted according to the probability of each outcome.
[itex]\langle A\rangle\equiv \sum_{i}P(a_{i}) a_{i}[/itex]
The observable [itex]A[/itex] can be expressed in terms of its eigenvalues and eigenstates as:
[itex]\hat{A}=\sum_{i}a_{i}|a_{i}\rangle\langle a_{i}|[/itex], where [itex]\hat{A}|a_{i}\rangle=a_{i}|a_{i}\rangle[/itex]
The probability of a given outcome is given by the state of the system [itex]|\psi\rangle[/itex] and the Born rule:
[itex]P(a_{i})=|\langle a_{i}|\psi\rangle|^{2}=\langle \psi|a_{i}\rangle\langle a_{i}|\psi\rangle[/itex]
Combining these together, we find the expectation value:
[itex]\langle A\rangle= \sum_{i}\langle \psi|a_{i}\rangle\langle a_{i}|\psi\rangle a_{i}[/itex]
With a little algebra, this becomes:
[itex]\langle A\rangle=\langle \psi|\big(\sum_{i}a_{i}|a_{i}\rangle\langle a_{i}|\big)|\psi\rangle =\langle \psi|\hat{A}|\psi\rangle[/itex].