。
She chose a hat to match her new dress.
Literal
She [topic-は] new dress [to-に] matching hat [object-を] chose.
The relative clause ドレスに合う ('that matches the dress') modifies 帽子 — the hat is defined by its relationship to the dress. 合う (あう, 'to fit, to match, to suit') takes に for what something matches with. This is a natural example of how Japanese pre-positions modifying clauses before the noun they describe.