Someone asked why did God put codes and rules in the Bible if we were not supposed to live by codes and rules.  

Well, He did put codes and rules forth temporarily until the Seed should come.  Beforehand, righteousness was all promised.
Galatians 3:11-12 But that no man is justified by the law in the sight of God, it is evident: for, The just shall live by faith.  And the law is not of faith: but, The man that doeth them shall live in them.
Why did God give a Law since no man could be justified by the Law?  This is basically what this person has asked me.  If the just shall live by faith alone, then why did the Law ever come?

Notice the point made next about justification.
Galatians 3:7-9 Know ye therefore that they which are of faith, the same are the children of Abraham.  And the scripture, foreseeing that God would justify the heathen through faith, preached before the gospel unto Abraham, saying, In thee shall all nations be blessed.  So then they which be of faith are blessed with faithful Abraham.
Hear this?  The topic is justification.  A just person is someone who lives righteously.  And God would justify the heathen through FAITH.  To be justified by God was to have been made into such a person that you would be committing acts of righteousness.  Otherwise you wouldn't be just.  And notice that GOD MAKES US JUST.  
Galatians 3:11 But that no man is justified by the law in the sight of God, [it is] evident: for, The just shall live by faith.
The LAW cannot justify anyone.  But that is what the purpose of the Law was for.  If man could obey every law then man would be considered just in the sight of God.  But God knew man couldn't keep it, hence He foretold that the just would live by FAITH.
Galatians 3:19 Wherefore then serveth the law? It was added because of transgressions, till the seed should come to whom the promise was made; and it was ordained by angels in the hand of a mediator.
The Law came to show man that we cannot make ourselves just.  Law was only a temporary means of teaching us a lesson.  It didn't cancel out the promise to be made just by faith, which was given before Law came.  

Ask yourself, "Why did God promise justification by faith, and not works, and then turn around and give a Law of works before granting that opportunity of justification by faith?  Justification by faith came when Jesus brought in the Abrahamic covenant again.  What was the purpose of the Law being stuck in between the promise and the fulfillment?"

It was to ensure we never commit Adam's error again in thinking we can go to a source of knowledge of good and evil (which is really what the Law is - hence, the forbidden tree was a kind of Tree of Law) instead of relying on His life to be put within us that we might live righteously.  God ensured we appreciated His gift of righteousness, since we might not should we still believe we could attain it independently of God.  It's like
saying that man will hurt his head by hitting it against a brick wall.  But should man disagree, the command to hit you head is given.  After 1,500 years of Law, Jesus finally came and brought the gift of righteousness through the great trade.  (2 Cor. 5:21- he took our sin and gave us His righteousness).

The following verses show that God planned that man see his inability to live righteously without grace  through giving the law.

After all the 1,500 years of Law intended to make one righteous (as stated in Rom. 8:3) Paul said:
Romans 3:9-10 What then? are we better than they? No, in no wise: for we have before proved both Jews and Gentiles, that they are all under sin;  As it is written, There is none righteous, no, not one:
And verses 11-18 continue the quoting of Old Testament passages to prove that the Law made no one righteous.  Now remeber that the law's efforts were directed in making man righteous.
Romans 8:3 For what the law could not do, in that it was weak through the flesh, God sending his own Son in the likeness of sinful flesh, and for sin, condemned sin in the flesh:  That the righteousness of the law might be fulfilled in us, who walk not after the flesh, but after the Spirit.
The Law didn't do what God did through Jesus - fulfill righteousness in us.

Look at the reasons for the Law:
Romans 3:19-20 Now we know that what things soever the law saith, it saith to them who are under the law: that every mouth may be stopped, and all the world may become guilty before God.  Therefore by the deeds of the law there shall no flesh be justified in his sight: for by the law is the knowledge of sin.

Romans 5:20
Moreover the law entered, that the offence might abound. But where sin abounded, grace did much more abound:
(Law came to instill into man just how deeply Adam's sin had affected all humanity in throwing us all into sin).

Romans 7:12-13 Wherefore the law is holy, and the commandment holy, and just, and good. Was then that which is good made death unto me? God forbid. But sin, that it might appear sin, working death in me by that which is good; that sin by the commandment might become exceeding sinful.

Galatians 3:24
Wherefore the law was our schoolmaster to bring us unto Christ, that we might be justified by faith.
I must also mention that Law served another purpose.  It reflected God's righteousness.  It contrasted man's unrighteousness from God's righteousness.  And we still must do the righteous deeds the Law tried to get us to do through self-exertion.  But we now do them through FAITH in the proxy death for us all by Jesus Christ, and subsequent faith in allowing God's Spirit to live through us.

Galatians 2:20 I am crucified with Christ: nevertheless I live; yet not I, but Christ_ liveth in me: and the life which I now live in the flesh I live by the faith of the Son of God, who loved me, and gave himself for me.