She studied hard so as not to fail the exam.

Literal

She [topic-は] exam [target-に] not-fail [so as not to-ないように], with-all-her-might studied.

The negative-purpose pattern [verb-ない]+ように 'so as not to X' here pairs with the four-character compound 一生懸命に ('with all one's might,' literally 'stake one's whole life'). The に on 一生懸命 makes the adverbial use explicit; bare 一生懸命 would do the same job and is more common in casual speech, while 一生懸命に reads slightly more deliberate or written. The comma after the purpose clause gives the sentence a brief breath, also more typical of written prose. The structure is one of the most common ways in Japanese to motivate a strenuous effort by what it aims to avoid.