Human or societal agreement It's a practical emergence of ways of functioning.
An individual or group of individuals might decide their way of functioning is to give away everything they come into ownership, except what they need to survive. This puts them in trouble whenany supply of resources isn't attainable, so they have nothing to fall back on, so either they change their way of behaving, or they end up living on the street, or they die....so that mode of behaving doesn't survive and spread well in society.
An individual or group of individuals might decide that they will behave in a way which exploits all manner of means to obtain what they need and excess too. This might bring them into conflict with other parts of society, if they end up breaking existing laws...this mode of operation, seems to be sustainable to some extent, as there is always the possibility of storing resources, and as long as there is a society to exploit, there may be avenues of obtaining resources.
If the exploitation mod becomes too prevalent in society, then society begins to break down, which leave fewer and fewer avenues for the exploiters to obtain resources.
So there is always an emergent form of behaviour within society, with a play off mainly between the creators of resources, and the exploiters.
There may be various philosophies that individuals or groups, have which lead them to behave in one way or another., though..
Law also emerge to try and sustain the production of resources.
But if it doesn't affect the production of resources, it seems like one society is quite capable of exploiting another society, eg the production of materials, the mining of minerals, in other countries that us slavery....so this makes me think the behaviour of any society is based mainly on what sustains that society, and less based upon some moral philosophy.
'do unto others as you'd have done to you' gets turned into 'you can't do it to me(because you are a poor slave in a foreign country), so I can do it to you'...and I don't have to do anything about it, as I am just following the mode of my own society.
As to 'agreement', all you have to do is choose your own mode of behaviour, there isn't really any need to agree to anything, is there?