It doesn't matter whether the players play good moves or bad moves there is a maximum possible number of moves. There is a rule which guarantees this - the 75 move rule. It says that if 75 moves are played without either a pawn move or a capture then the game is drawn.
The relevant article of the FIDE Laws of chess is 9.6.2-
9.6 If one or both of the following occur(s) then the game is drawn:
9.6.1 the same position has appeared, as in 9.2.2 at least five times.
9.6.2 any series of at least 75 moves have been made by each
player without the movement of any pawn and without any capture. If
the last move resulted in checkmate, that shall take precedence.
So, once every 75 moves a piece must be captured or a pawn moved (forward). Eventually all the pawns have queened or been captured and all the pieces captured and only the kings are left - which is a draw.