It is always the best five cards that make a five card poker hand that determines the winner loser or split. Holdem is played with seven cards, and the two cards that are not part of the best five card hand count for absolutely nothing in determining if a pot is won lost or split.
It's primarily a skill game, although luck plays a huge role. In any single given hand, luck is the predominant factor in who will win or lose. However, poker players don't play a single hand. They play hand after hand after hand & and overall, skill dominates.