I am new to music theory and I was wondering what the difference is between harmony and consonance/dissonance. What are the reasons behind these terms and how can you apply it in practice if, for example, you'd like to compose a song?
Harmony is a noun that means "simultaneous sounds." Consonant and dissonant are adjectives that describe harmony; think of dissonance as "tension" and consonance as "stability/release."
In terms of composing a song, you'll often want your harmonies to match what's happening in the lyrics. If a song ends "happily ever after," it doesn't make much sense for it to end with a dissonant (=full of tension) harmony, does it? Similarly, if the song ends with a major disruption in the lyrics, it might be nice to end with a slightly dissonant chord. If your song is a story of turmoil moving to triumph, you could tell that story with the harmonies by progressively moving from dissonance to consonance. These examples are pretty one-dimensional, and the best music is much more nuanced than this, but they give you a decent starting point.
Lastly: Colloquially, "harmonious" has come to mean something like "consonant," and every once in a while someone (typically a non-musician) will say "harmony" and mean "consonance." Just be aware that sometimes people use these terms interchangeably, even if they're incorrect.
Harmony is a general term relating to the putting-together of differently-pitched sounds (possibly of different timbres) to create subjectively interesting effects.
Consonance and dissonance are more specific words - Consonance ⇔ Dissonance is a spectrum along which different harmonies can be classified as sounding 'smoother' (consonant) or 'rougher' (dissonant). Note that it's not possible to fully understand harmony by measuring it along this axis alone - you also need to consider aspects like voice leading, and the emotions that tend to be subjectively associated with different types of chord.
Sometimes people (speaking more 'informally', from a musical perspective) use the word 'a harmony' to mean 'a consonance', and 'harmonious' to mean 'consonant'.