He happened to meet her there.

Literal

He [topic-は] there [at-で] by-chance her [with-に] met.

偶然 ('by chance / coincidentally') is an adverb that slots in front of the verb to color the entire action as unintentional. The で marks the location where the meeting happened (location of action), not the location of existence. 会う takes に for the person you meet — に marks the target of the encounter rather than を, even though English uses an object: 'meet someone'. This is a quirk of how Japanese conceptualizes the verb: you 'meet to / converge with' someone rather than 'act upon' them.