Can studying in a good place hurt your application?
As others have pointed out, anything can happen.  Of course if you are at the weaker M.S.  school, emphasize your class rank, etc.  But my Bayesian estimate is that you (one) are better off at the STRONGER school.  It will challenge you more, move you more etc.  

Don't try to be a big fish in a small pond. Go out in the ocean and compete with the Great Whites.  Consider Arnold Schwarzenegger.  He didn't stay in the cowtowns of the Steiermark.  He went to Muscle Beach in California.  "New York, New York...if you can make it there, you can make it anywhere."  Be a playah.  

Note:  if there are other reasons, family, weather, economics, pedagogy, etc. that you (one) prefers the easier school, fine.  Of course what matters most is the student, not the school.  If you have the goods, you can prevail anywhere.  But all else equal...go to the harder school.

Just a point of view, but hopefully explaining what is behind the pick.