This question already has an answer here:
- Onto maps between two finite sets 3 answers
What is the number of surjective (onto) functions from the set  to the set .
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
We first count the complement. There are $2^5$ functions that "miss" $1$, also $2^5$ that miss $2$, and $2^5$ that miss $3$. Add. We get $3\cdot 2^5$.
But we have double-counted the functions that miss both $1$ and $2$, also the functions that miss $2$ and $3$, also the functions that miss $3$ and $1$. There is $1$ (or if you prefer, $1^5$) of each kind, so we subtract $3\cdot 1^5$.
Thus the total number of onto functions is $3^5-3\cdot 2^5+3\cdot 1^5$.