The number of sharps and flats in the key signature determines the key of a musical piece. This determination is relative to the Circle of Fifths because it annotates what sharps or flats will follow in that key.
For instance, if there are no sharps or flats in the key signature it is in the key of C (because there are no sharps or flats in a C Major Key signature). To find what key a song is in, simply match the sharps or flats with those in the Circle of Fifths, and that will yield the key signature.