Sea Breeze: The question is why can we do that?
The "why" is irrelevant. In fact, I can demonstrate that it is irrelevant even if god exists.
Let's start by dismissing the idea that god has 'written a law in our hearts.' If this was the case, laws and moral codes would be superfluous. Why do we need laws and moral codes? Because the most base human motivator -the one we are born knowing above all else- is selfishness. What do parents need to do for their children? Teach them and discipline them to help them rein in their selfish nature and become useful members of society.
How do they begin? By using that selfishness to help them develop empathy, which is the first basis of moral behavior. How many times have we heard a parent tell a child "how would you feel if this was done to you?" Even when we are older and able to use logic and reason to understand why we have codes and laws, we still use empathy to no small degree.
Later, we can use our knowledge and understanding and experience to draw logical conclusions regarding the need for laws and moral codes. Put simply, what would happen to a society that decided that murder, theft, rape, and deception were normal behavior that was not controlled? It would destroy itself. How does a human society thrive? By addressing our in-built selfishness, through moral codes and through laws and law enforcement. If goodness was our natural state, none of this would be necessary.
There, we have a simple approach to determining right and wrong. We use it all the time and throughout our lives. There should be no question that this is the case. Because we can do this, we do not need someone to implant these in our minds. Even if god existed, his input is unnecessary; we have a clear and sensible basis for developing morals and determining what is right and what is wrong. The history of human laws demonstrates that this development was gradual and tracked with societal development, which also makes sense. The bigger and more sophisticated our societies became, the more sophisticated our laws had to be.
That is why we can do that. It strikes me that a species that is so driven by base desires like selfishness and sexual gratification aligns more closely with evolution than with the kind of god you claim to worship. A god who creates a world like this comes across as something of a sadist.