They can be difficult to use correctly. The ending (이다, 하다, 되다) gives you a clue as to the correct usage, but 하다 needs special attention as it can be both a verb ending (안도하다, 안심하다) and adjective ending (후련하다), which makes a big difference.
1. 다행이다(a): It is fortunate that ... (said of a situation, often without the subject)
* 사고 났지만 안 다쳐서 다행이야 = It's fortunate that you didn't get hurt in the accident.
2. 안도하다(vi): be relieved (because the matter of concern has been taken care of).
* 어머니는 동생이 무사하다는 말을 듣고 안도했다 = Mom was relieved hearing my brother was okay. (usually a person is the subject)
3. 안심되다(vi) = 안심이 되다: have no fear/worry, feel relieved after receiving assurance, etc.
* 형이 옆에 있어서 안심이 됐다 = I wasn't worried because my brother was by me. (subject can be a person, or omitted)
4. 후련하다(a): feel freed from something burdening (getting out of pressure/annoyance, not worry as with the others).
* 입학 시험을 치르고 나니 속이/마음이 후련하다 = I feel free/off the hook now that the entrance exam is over. (subject is one's feeling, sentiment, etc, or omitted.)
다행이다, 후련하다, 안심(이) 되다 are all-around words commonly used.
안도하다 is more formal. 안심하다(feel everything is okay) is its more informal version.