That depends on many factors. If the child is likely to be harmed by a pet, such as by an allergic reaction, the answer is obviously no. And if children are likely to harm pets they shouldn't have any.
But for kids who don't fall in either obvious category, here are some factors to consider: Will the pet require care the child is unable to give? If so, can someone else provide it? If the child is likely to be hospitalized for extended periods can the pet be left alone or is other care available? Might sanitation be a problem?
And if a pet is appropriate, what kind is best?
Many kids can benefit from the affection and physical contact of a cat or dog while others might enjoy watching fish or other creatures in an cage or terrarium for extended periods. A small rodent can provide both some warm, physical contact and time to watch them from outside the cage.
Even children who can't have their own pets can benefit from animals such as therapy dogs and horses. A good example of that is this book about a therapy horse: http://andyandthealbinohorse.blogspot.com/