The story
Commonly believed to be from the days of flintlock and caplock firearms, where the half-cock position of the hammer was both a rudimentary safety and the proper position for priming the pan or inserting a percussion cap. The phrase was originally rendered as "to go off at half-cock." However, this expression comes from archery. The coloured feather on an arrow is called the cock feather. The arrow must be drawn back fully so the arrow will fly the furthest distance. Going off half cocked means the arrow will not achieve its full power and not reach its target.
Etymology from Wiktionary, CC BY-SA 4.0.