Let f: {1, 2, 3} → {1, 2, 3} be an onto function. Then, f is
one-one and onto
If f is not one-one, then image of any two elements of domain, say 1 and 2 will have same image, say 1 in the codomain.
That means, element 3 of domain can be mapped with any of the two elements 2 or 3 in codomain, leaving one element in the codomain unmapped which is a contradiction.
Hence, f is one-one.