The Declaration of Independence was written for several reasons, all having to do with the unfair practices of Great Britain in the colonies.
The disagreements between the colonists and the monarchy began in 1765, and went all the way until 1776. Great Britain had enacted several taxes on key products used in the colonies. These included the Stamp Act (1766), the Townsend Acts (1767), and the Intolerable Acts of 1774 (Barton & Barton, 2020, pgs. 134-154). Britain also dissolved colonist-led legislatures through Crown-appointed high-ranking politicians. The colonist fought back on these acts, seeking to reconcile their relationship with their home country, but the King flat-out refused.
It was evident to the colonists that Great Britain would continue to grow more tyrannical and restrict their freedom. They eventually drafted the Declaration of Independence, severing their ties to Britain, in the midst of fighting that had already been underway for 14 months (Barton & Barton, 2020, pg. 151).
References:
Barton, D. & Barton, T. (2020) The American Story - The Beginnings - Pages 134-154