As Mike and Antoine already explained, we pick the best chain by total accumulated work, not by height, where the work is counted per the blocks' difficulty. However, the original release of Bitcoin did actually use the height to pick the best chain, which was replaced with "most work" after people noticed this attack surface just like you did.
You cannot redo the work from block 1, because Bitcoin Core commits to a series of checkpoints that hard-code specific block hashes at specific heights. The youngest is at height 295,000 which is buried some eight years now. This protects against new nodes falling for extremely low-difficulty fake chains, even though the difficulty is about 5,000× higher today than that of the last checkpoint block.
Further, some years ago, Bitcoin Core introduced header-first synchronization: before Bitcoin Core will request any single block, it'll request the whole header chain from one peer (up to that peer's best chain tip). Since the header is sufficient to determine whether a block passes the difficulty requirement, a new node can use the less than 60 MB header chain to see whether what it's been given passes has more work than a sanity parameter called
minChainWork. The node will only start requesting blocks from peers after it has received a header chain whose cumulative work exceeds
minChainWork by two weeks worth of work. So, for an attacker to get you to even download a single block, their chain has to exceed a total work within a magnitude of Bitcoin's total work.