In Numbers there is the story of the man who gathered sticks on the Sabbath and then God commanded the people to kill the man. However the 10 commandments make it clear that to kill is wrong. I understand why this man was to lose to his life but not why God would have people do it, people also instructed not to kill.
Then the Lord said to Moses, “The man shall surely be put to death; all the congregation shall stone him with stones outside the camp.” Numbers 15:32-36