Let the hats of monkeys A, B and C be a, b and c respectively.
This table shows the ways in which the monkeys can select hats.
A
B
C
a
b
c
a
c
b
b
a
c
b
c
a
c
a
b
c
b
a
In only two of the six ways do none of the monkeys have the same hat as when they arrived, hence the required probability is
$$\frac{2}{6}=\frac{1}{3}$$