Murder has been illegal in the USA for likely 400 years which is around the time when law enforcement started.
The murder would not be illegal until law enforcement came around or laws existed because you need a law to be in place and law enforcement to actually do anything about something that is illegal.
400 years ago though law enforcement was basically in it's infancy but as the time went on more and more laws began to come into place.
I'm not sure how murder actually became illegal though but it must have been due to mass murders happening years ago.
If murder wasn't illegal then there likely would be more murders happening now.
But then again although murder is illegal in the USA the state can murder someone for murdering someone which doesn't make it right.