Hess’s heir agreed to allow the painting to stay on display at the museum after various donors, including the German federal and state governments and the Ernst von Siemens Foundation, raised money to compensate her, the German government said on Friday.