Using your question as an example: Nearly every species on the planet has a built in survival instinct. Logically that instinct within those species who develop societies will permeate into that society's rules; from ants and hamsters to dolphins and humans.
Members of the species who follow that inherent, built in "moral code" don't need external rules to point out behavior which have proven to benefit that society.
Those individual members who are not in touch with that instinct need those external rules since their ability to instinctively follow them on their own is diminished.
Hence, "the law is for the lawless".