So a declaration of war is made when you wanna go to war with someone else (duh).
For example, country A hates country B's guts. A declares war on B. A and B go to war. One side wins, unless the whole world gets embroiled in it, then things get way more complicated.
So why not skip the declaration?
Country A hates country B's guts. A carries out a sudden invasion. B is probably dead.
Is there a reason to declare war during a time period before modern history? (Outside of ethical reasons and things like a knight's honor)
It seemed to me that declaring war against another country you wish to invade is just a really stupid thing to do. It's like telling someone that you want to murder that you are gonna shoot them (thus giving them time to run or fight back).
Of course there might be a few problems, B:"Why are you amassing your army beside our border? You dare go to war with us?" A:"Nope, we definitely not going to war with you, we would have declared war if we wanted to." The element of surprise would definitely be lost if the enemy finds a large encampment of soldiers outside their border but if it was planned well, it could be a devastating invasion where B was unable to mobilize their soldiers well.
This is also assuming that there were no international laws that prohibits both the threat and the use of force in international conflicts, which have made declarations of war largely obsolete in international relations in the modern era.