BEIJING — A Chinese court sentenced a nanny to death on Friday for setting a fire that killed three children and their mother, in a case that has prompted a national discussion about greed, trust, inequality and neglect.

The nanny, Mo Huanjing, 35, was convicted of arson for igniting her employer’s apartment in June. The authorities said Ms. Mo, who had more than $9,500 in gambling debt, had planned to start a fire and then extinguish it, hoping that the family would reward her financially for coming to their rescue.

In its decision on Friday, the Hangzhou Intermediate People’s Court in eastern China called Ms. Mo’s motive “despicable” and said that she had “seriously damaged public security and caused social harm.”