She had a hard time soothing the child's heartache.

Literal

She [topic-は] that child [genitive-の] heart-pain [object-を] heal [for-のに] struggled.

~のに苦労する ('have a hard time doing [X],' lit. 'struggle in order to do [X]') uses ~のに in its purpose-marker sense — 'in the act of, in order to.' Inside, いやす (癒す) is the soft, healing verb — 'to soothe, to heal,' often paired with emotional or psychic wounds rather than physical ones. 心痛 ('heartache, mental agony,' lit. 'heart-pain') is a Sino-Japanese compound with literary flavor; in everyday speech, 悲しみ ('sadness') or 辛さ ('pain') would be more common. The whole sentence describes the slow work of consoling a child.