I think it's closely related to our genetics.
We all have a 'sympathetic system' which mimics other peoples state. It's why if another person gets angry, we get angry (often we later consider it to be irrational - but it's a result of this system). It's why two people 'together' walking side by side fall into step. It's why the very best salesmen even have their breathing fall into line with their customers. etc. It's the root source of 'empathy' (being able to feel what another person is feeling). It's purpose is social cohesion, which aided survival in caveman days.
If you look at 'purpose' of all of that - social cohesion and survival...I think you start to see some of the foundations of 'conscience' coming into play.
Our brains of course, have several areas with different functions. We have our primal brain which deals with instincts, a part of the brain that deals with emotions, and a part of the brain that deals with logic (they are the 3 major parts, there's other parts too). They interact, but don't always form a consensus.
I'm quite certain that apart from our sympathetic system, we then learn many parts of right from wrong (formed as neural connections in the brain), which are still closely related to social cohesion...but can differ in aspects from culture to culture (hence they must be learned values). And the breaking of these triggers our social cohesion instincts.
We also have 'imagination', which allows us to run scenarios and likely outcomes in our minds...which can again trigger social cohesion instincts, or even self preservation instincts.
All a part of 'conscience'.
Just my thoughts.