GHz is the measure of the clock speed (think about a metronome ticking). The GHz just tells you how many times per second the clock on the CPU will tick (Not exactly, there is an equation to figure it out, but just know that 3.0 and above is considered fast). On each tick tasks are run in CPU to process data. So, if you have a CPU with more GHz the clock will tick faster and thus, more tasks can be completed in a shorter amount of time, making your computer faster.
Obviously its quite a bit more complicated than that, but this was just to give you an analogy to understand how it all works.
Keeping all this in mind, the second CPU you mentioned will be faster than the first.