Remember the story of Uzzah (2Sam. 6:1-11; 1Chron. 13:1-11)?
While transporting the ark of the covenant from Kirjathjearim to the city of David, the oxen that carried it stumbled and shook it. Uzzah, according to scripture, put his hand on the ark to hold it in place. However, God was angry that Uzza had touched it and, therefore, killed him for it. Uzzah (also spelled Uzza) was only trying to help. He had good intentions when he touched the ark; however, he disobeyed God by doing so (see Num. 4:15, 19, 20). This shows us that good intentions are no excuse for disobedience.
Intentions do matter because they are the motives behind our actions. People often do things under false pretenses. Even though they do good, their motives for doing so may not be so. We can do good but have wicked motives for doing it. Likewise, we can do wrong although we have good intentions (as in Uzza's case). Thankfully, God reads the hearts of men and knows their intentions, whether they are good or bad.