when did the war start?
19 April 1775
American Revolutionary War
Fighting broke out on 19 April 1775 
what was the main purpose for writing the declaration of independence It was a formal explanation of why Congress had voted to declare independence from Great Britain, more than a year after the outbreak of the American Revolutionary War.
wiki:1574759
American Revolutionary War [SEP] Introduction
When Parliament answered with punitive measures on Massachusetts, twelve colonies responded with the First Continental Congress to boycott British goods. Fighting broke out on 19 April 1775 when the British garrison at Boston were sent to destroy a colonial Assembly powder-house and were harassed by local militia at Lexington and Concord. In June the Second Continental Congress appointed George Washington to create a Continental Army and oversee the capture of Boston. When their Olive Branch Petition to King and Parliament was rejected, the Patriots attacked British Quebec but failed. In July 1776, Congress unanimously passed the Declaration of Independence. Hopes of a quick settlement were supported by American sympathizers within Parliament who opposed Tory Prime Minister Lord North's "coercion policy" in the colonies.