Because it's the best 5 card hand using any combination of community cards and your cards. If you have JJ in your hand and no one has any pair higher than JJ in their hand or with one card in their hand and another card on the board then you have the best hand, a pair of sixes (no matter where they come from) loses because you have a better hand with your pair of JJ.