Having two toes facing in opposite directions helps the birds cling on to the side of the tree better. By the way, these birds are said to have zygodactyl feet. Zygodactyl is just the scientific way of saying two toes pointing front and two toes pointing back. The strangest feet on any bird I have ever seen are those on coots and their cousins. These claws lock in place once the bird grabs something and don't let go until the raptor wants to let go.
Herons are also unusual.
While their feet don't LOOK any different, they use them differently. They do this to attract the fish. The fish see something moving under the water and wonder what it is. So the next time you go out bird watching, don't just admire the bird s feathers or its song. It might just be sitting there, but look at HOW it's sitting.