A declaration of war is one nation's official announcement to the world that it is at war. The declaration always identifies the nation or nations against which war is declared, and often is accompanied by a list of grievances justifying the declaration, essentially blaming the other country or countries for the state of war. The 1907 Hague Convention on the Opening of Hostilities set forth the protocol for declarations of war.
The protocol of how a declaration of war is issued and who issues it varies by nation. Probably the most famous declaration of war of modern times was that requested by United States President Franklin D. Roosevelt in his speech to Congress announcing the Japanese sneak attack on Pearl Harbor in 1941. Many incorrectly interpret the speech itself as the declaration of war, but the US Constitution reserves the power to declare war to the Congress; the president simply asked the Congress to exercise that power, which it did on December 11, 1941. Other nations authorize the head of state or the head of government to declare war. The United Kingdom, for example, bestows the right to declare war on the prime minister.
A declaration of war is not an absolute prerequisite to conducting a war. Most conflicts between nations that might meet the definition of a war, in fact, haven't been declared by either side. The United States, for example, has declared war on just five occasions in its history, against a total of 10 nations. The last war declared by the United States was World War II. Other wars in which the Unite States has been involved, such as the Korean War and the Vietnam War, were not declared.
The declaration of war by one nation against another has a long history, and is mentioned in the Old Testament. It served to alert non-involved nations, in particular, that a state of war exists, and invoked commonly-accepted rules and standards for the conduct of the war. Modern-day conflicts, however, don't always lend themselves to declarations of war, especially when the enemy is not a recognized nation.
It's also said that a declaration of war, especially if actual armed conflict has been minimal, imprudently advises an enemy and permits him to prepare his defenses. In 1941, Japan issued a long statement to the United States declaring peace negotiations to have ended. While it didn't constitute an actual declaration of war, the Japanese strategy was to deliver the message about 30 minutes before the attack on Pearl Harbor, giving the United States very little time to prepare its defenses. In fact, the message was delivered after the attack had commenced.
With respect to the conduct of war itself, many nations involved in hostilities with other nations tend to follow the rules of war, such as the Geneva Conventions, with respect to the treatment of prisoners of war, even in the absence of a formal declaration. There's controversy, though, over the applicability of such treaties and conventions if the enemy does not represent a nation or a recognized government. Some of the controversy is practical; in the absence of a formal surrender or withdrawal, there is the question of how the end of the conflict is to be recognized for the purpose of releasing and repatriating POWs, particularly those who belong to a rebel guerrilla army instead of representing a traditional country with geographical borders.