It's an evolved characteristic of mankind, plus a natural tendency to avoid bad things being done to you.
I'll give one example of the first from our evolutionary past. It's generally considered that incest is wrong (let's not get into an argument as to the validity of that statement). Those that might have indulged back in the deep past will have had offspring that were not as 'fit', in an evolutionary sense, as those that didn't. So those that tended to have sex with close relatives died out. leaving those that, due to a throw of the evolutionary dice, thought it might not be a good idea. Nobody did studies in Palaeolithic times to check. It was just evolution doing what evolution does best.
Now, had it been a quirk of our biology that having sex with close relatives was evolutionary beneficial, then the result of that would be that those who had sex outside of the immediate family would have died out. And that having sex with a stranger would now be seen as morally wrong as compared to having sex with one's siblings.
In the second case, it's pretty simple. If I steal your stuff, then you're going to steal mine. If I share my stuff, then there's a chance you'll share yours. Simply extrapolate from that and not stealing and sharing what you have become 'good'. So we call it moral.
Actually, the sharing can be used in the first sense as well. People who have a tendency to share form groups. And finding food, making tools, building a shelter, is easier if there's a few of you than if you're an individual. If you're part of a group, then one person can look for food while another is making weapons to hunt for that food while you are building a shelter and someone else is lighting a fire. The guy who thinks sharing is for losers has to do it all himself. He doesn't make it and therefore has no descendants. But the descendants of the group all have a 'sharing gene' and it becomes predominant.
Now that's a complex matter that might take a book or two to deal with in detail but it's only a couple of paragraphs. So bear that in mind.