Galatians (like all of Paul's letters) contains long strings of argument that overlap and merge. So it's difficult to know where to start. For the sake of argument, let's start with Galatians 3:15-18 (ESV):
To give a human example, brothers: even with a man-made covenant, no one annuls it or adds to it once it has been ratified. Now the promises were made to Abraham and to his offspring. It does not say, “And to offsprings,” referring to many, but referring to one, “And to your offspring,” who is Christ. This is what I mean: the law, which came 430 years afterward, does not annul a covenant previously ratified by God, so as to make the promise void. For if the inheritance comes by the law, it no longer comes by promise; but God gave it to Abraham by a promise.
Ok, so Paul is asserting that strict adherence to the law of Moses isn't necessary since the promise came before the law. The example here suggests that once both parties sign a contract, neither party can go back and change the contract, so God cannot go back and change the promise He made to Abraham. Paul also makes a bit of a leap to say that the promise of Genesis 12 refers to Jesus and not just Issac or the children of Abraham. (This could be the subject of another question.) The connection is especially important since in verses 7-9, he makes a case for a Gentile claim on that very promise. The idea is that the promise is fulfilled thought Jesus.
Moving onto Galatians 3:19-20 (ESV):
Why then the law? It was added because of transgressions, until the offspring should come to whom the promise had been made, and it was put in place through angels by an intermediary. Now an intermediary implies more than one, but God is one.
Now Paul anticipates the question, "Why then the law?" The answer is "because of transgressions". Maybe you know what that means, but to me that's not really answer. It seems to me that the law would need to be in place before someone could transgress against it. Let's put aside the "intermediary" for a moment because Paul elaborates on the purpose of the law in Galatians 3:21-22 (ESV):
Is the law then contrary to the promises of God? Certainly not! For if a law had been given that could give life, then righteousness would indeed be by the law. But the Scripture imprisoned everything under sin, so that the promise by faith in Jesus Christ might be given to those who believe.
Paul here anticipates another question. This time he's pulling in a thread he started in verses 10-14 about where we can expect to receive righteousness from. His point here is that the blessing comes via the promise to Abraham inherited by Jesus who passes it onto Gentiles. The function of the law is "imprison everything under sin". Again, it isn't exactly clear how that works since usually we are imprisoned because of a law and not by it. Galatians 3:23-29 (ESV) elaborates:
Now before faith came, we were held captive under the law, imprisoned until the coming faith would be revealed. So then, the law was our guardian until Christ came, in order that we might be justified by faith. But now that faith has come, we are no longer under a guardian, for in Christ Jesus you are all sons of God, through faith. For as many of you as were baptized into Christ have put on Christ. There is neither Jew nor Greek, there is neither slave nor free, there is no male and female, for you are all one in Christ Jesus. And if you are Christ's, then you are Abraham's offspring, heirs according to promise.
The "we" pronoun must refer to Jews since the Mosaic law didn't extend to Gentiles. Remember that the law was given just as Israel left Egyptian captivity and were finally able establish their own nation. Paul shifts from the image of the law as prison to the law as guardian. So the law binds or protects Israel, the conduit of the Abrahamic promise to Jesus, from abandoning God.
At the risk of confusing things with yet another analogy, consider the process of taking your dog to a dog park. Once he's there, he'll have the freedom to run around, sniff other dogs' butts, play fetch, and so on. But in order to get him safely to the park, you have to put him on a leash. Otherwise he might run off and get run over by a truck or something. The law is a little bit like a leash.
So back to the intermediary, at last. Galatians 3:19b-20 (ESV):
[The law] was put in place through angels by an intermediary. Now an intermediary implies more than one, but God is one.
The person who put the law into place was Moses. It's appropriate to call Moses an intermediary, since in when he comes down the mountain and sees the people worshiping a golden calf, it's Moses who convinces God not to destroy the people and start over. As Paul argues, the Mosaic law continued to mediate between God and Israel until Christ. But what is our intermediary after Christ, and between Gentiles and God?
The obvious answer is Christ, who fulfills the promise to Abraham. (Other New Testament texts take this position: 1 Timothy 2:5, Hebrews 8:6; 9:15; 12:24.) But the thrust of the argument of Galatians, which continues into chapter 4 and 5, is that the mediator isn't needed anymore. Galatians 5:16-18 (ESV) suggests the relationship has changed:
But I say, walk by the Spirit, and you will not gratify the desires of the flesh. For the desires of the flesh are against the Spirit, and the desires of the Spirit are against the flesh, for these are opposed to each other, to keep you from doing the things you want to do. But if you are led by the Spirit, you are not under the law.
Instead of two opposing parties, the image Galatians proposes is cooperation or working together as a family. Instead of being enslaved by the law, we are bound to God via our gratitude to Jesus and the guiding of the Spirit. (To use the analogy of the leash, we don't need to be physically tied to God anymore because we are tied by love and devotion.)
There are two ways to read "but God is one":
It's solely to highlight the need for Moses and the Law to provide an intermediary before Jesus.
It also asserts a proto-trinitarian theology.
The support for the first is strong in Galatians (as I've already laid out) and weaker for the second. Assuming Paul claims we no longer need a mediator, I don't think #2 really applies.
Summary
The function of the law according to Galatians is to be a mediator or guide for Israel from the time of Moses to the time of Jesus. It stood between God and his people so that the promise to Abraham could be passed onto the Gentiles.