What effect do random visitors have on children in orphanages and people in old age homes?
There is indeed research done on the topic. Some links:
http://www.thinkchildsafe.org/thinkbeforevisiting/
http://www.hsrc.ac.za/HSRC_Review_Article-195.phtml
http://www.thinkchildsafe.org/thinkbeforevisiting/resources/Misguided_Kindness.pdf
http://www.thinkchildsafe.org/thinkbeforevisiting/resources/UN%20Guidelines%20Alternative%20Care.pdf
http://en.wikipedia.org/wiki/Volunteer_travel  

Extracts:  


  A child's right to privacy Under international law, children in
  orphanages have the same rights as children across the globe to have a
  safe and private home setting. Short-term orphanage visits from
  tourists and travelers lowers a child's privacy inside their own home.
  Additionally, reports show that short-term visits can cause harm to a
  child's development and emotional wellbeing. We think everyone agrees
  that children need safety, privacy and stability.


and  


  How do I harm children by visiting an orphanage?
  Many orphanages rely
  almost entirely on donations from visitors to survive. Thus directors
  may purposefully maintain poor living conditions for children to
  secure funds from tourists. Children who appear underserved may come
  across as a cry for help more than children who appear well fed and
  cared for. This of course places guilt on tourists if they do not help
  immediately. By visiting orphanages and making a donation you may be
  fuelling a system that exploits children.


and


  Institutionalised children will thus tend to manifest the same
  indiscriminate affection towards volunteers. After a few days or
  weeks, this attachment is broken when the volunteer leaves and a new
  attachment forms when the next volunteer arrives. Although there is
  little empirical evidence on children's reactions to very short-term,
  repeat attachments over time, evidence from the study of children in
  temporary or unstable foster care indicates that repeated disruptions
  in attachment are extremely disturbing for children, especially very
  young children.