Morality is definitely tough to define, I think there are several different types of it used under one term.
I do believe that we might have certain "moral codes" instilled in us (and perhaps in other animals) by nature. Murder for example I can imagine murder being one, along with certain other "basic" morals.
(ex.
http://www.nytimes.com/2007/03/20/sc...=1&oref=slogin )
The other "morals" in the other hand may be just a product of society, where & how we are raised & what we are taught. The obvious need for this of course rises out of the need for people to co-exist in a more complex society.
I would probably group it in 3 categories
1 - Most fundamental, natural/genetic morals. Majority would hold agreement on these regardless of environment. ex. murder
2 - Basic rules/foundation of a functioning society. ex. regarding property etc.
3 - More minor moral "rules" which are likely to vary quite a bit (by time period, place etc). Things such as sexuality for example.
Laws I think are a combination of all 3. From murder being illegal to homosexuality (which I would place in the 3rd category)