She went to Germany to study medicine.

Literal

She [topic-は] medical-science [object-を] study [for-ために] Germany [to-に] went.

~ために expresses purpose with verbs of action — 'in order to.' The full clause 医学を勉強するために is a non-past verbal phrase modifying ために, which then chains into the main verb 行った. Germany has a long-standing place in Japanese medical history: from the Meiji era onward, Japan modeled much of its modern medical training on German universities and adopted German medical terminology — Karte (medical chart), Operation, and Krankenheit-derived vocabulary still circulate in clinical Japanese.