Weil, wegen and deshalb are three words that cause some problems when using them.
They express exactly the same, the cause (with the exception of deshalb, which expresses the consequence of an action) and belong to the so-called group of causal sentences in German .
1.The conjunction “weil” (subordinate conjunction)
Klaus geht nicht in den Park, weil das Wetter schlecht ist.
Klaus does not go to the park because the weather is bad.
We can see that the conjugated verb goes to the last position because weil is a conjunction subordinate.
2.The preposition “wegen”, genitive conjunction
Wegen des schlechten Wetters geht Klaus nicht in den Park
Acause of bad weather Klaus does not go to the park.The preposition wegen is used in the so-called “Nominalstil” (I have explained it in another article) and can be in first position or in the middle of the phrase.
3.The adverb “deshalb” together two main sentences
Das Wetter ist schlecht, deshalb geht Klaus nicht in den Park. Das Wetter ist schlecht, Klaus geht deshalb nicht in den Park
In this example we can observe that the adverb “deshalb” can occupy the first or third position. Stylistically it is usually better in the first position.
This is all about the differences between weil, wegen and deshalb