Guns were invented in Asia as a weapon against Mongols. They were created to combat the superior archery power of the Mongols who could pick off raiders and beseigers from great distances and hid behind the stone walls of what has now become the "Forbidden City" in China. The first guns were more like hand cannons that didn't have great aim, just a lot of boom and a little ball that the user hoped hit something.
Yes, guns were initially created as weapons. Yes, the purpose of a gun is to kill (whether it be another person or to be used for hunting)