Start with the system requirements and make sure your machine meets or comfortably exceeds them. That single check prevents most performance complaints before they happen.
Team Fortress 2 is not a demanding game by modern standards, so a mid-range machine from the last several years will run it well. If you want headroom, prioritise a dedicated graphics card and 8GB of RAM over a faster CPU — and buy a legitimate copy, since the free-to-play version is the official one and needs no workaround.