As of 2023, you can buy the latest iMac M1 (2021) directly from Apple's website, as well as on Amazon. However, it's tricky to find this iMac in new condition (and not as Renewed or Renewed Premium – which is Amazon's term for second-hand). You can still find earlier iMac models online from various retailers, often with significant discounts.
For a good iMac deal, or if you want a larger screen, the 2021 27-inch iMac is well worth looking at. iMacs earlier than this are really only worth buying now if you find a very good deal – perhaps on a renewed model.