This is a very important question, and when it comes to taking a life, the Bible does make a distinction between murder, which is taking a life for vengeance or some other indiscriminate reason, and the taking of a life for the purpose of punishment or military action, which assumes a defensive act.
Within the context of Israel's theocratic rule established in the Mosaic Law, God explicitly outlined a system of capital punishment for certain crimes. This practice was certainly active prior to the Mosaic Law and is still enforced in many lands to this day. Capital punishment is actually founded on the principle that all life is sacred.
The idea behind capital punishment is that the decision to take a life is never made by the ones who were hurt by the crime, but rather by those whose responsibility it is to impartially determine the motive and severity of the offense and to deliver an appropriate and justified response. I'm fully aware that some people believe that taking a life for a crime is never justified, and I respect that opinion, but it simply isn't supported biblically.
Part of the confusion in this matter stems from a rather unfortunate rendering in the King James Version of the Bible in the Ten Commandments which says:
Thou shalt not kill. Exodus 20:13 (KJV)
At face value this would seem to place a divine prohibition on the taking of any life for any reason. However, the more modern translations clear up the confusion by correctly rendering this verse as:
You shall not murder. (ESV)
The Hebrew word refers specifically to premeditated murder and also carries the connotation of human death caused through carelessness or neglect. Thus death brought as the result of justice or military action is not in view here.
The Apostle Paul spoke of the right of governmental authorities to dispense justice in Romans chapter 13. He wrote:
Romans 13:1-4 (ESV)
Let every person be subject to the governing authorities. For there is no authority except from God, and those that exist have been instituted by God. Therefore whoever resists the authorities resists what God has appointed, and those who resist will incur judgment. For rulers are not a terror to good conduct, but to bad. Would you have no fear of the one who is in authority? Then do what is good, and you will receive his approval, for he is God’s servant for your good. But if you do wrong, be afraid, for he does not bear the sword in vain. For he is the servant of God, an avenger who carries out God’s wrath on the wrongdoer.