system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5:Why must a country "declare war" before attacking?

Is it just a moral thing to do? wouldn't they take the advantage by attacking without notification?
gpt
It's part of an agreed treaty from the Hauge convention 

> The Contracting Powers recognize that hostilities between themselves must not commence without previous and explicit warning, in the form either of a reasoned declaration of war or of an ultimatum with conditional declaration of war.

And was adopted by the United Nations after its founding. 
It serves multiple purposes

1) All native and allied citizens are being informed to leave the country

2) It informs citizens of said country, thus limiting loss of civilian life

3) It informs allied and neighboring countries what is commencing so they can either not get caught in the cross fire or join in if they have an agreement with one of the nations

4) Is considered morally right in many eyes, the goal of most modern wars isn't the decimation of a country, but a specific action or actions. A formal declaration of war would include a list of demands, with the hope being a coup will take place to meet those demands.