You upgrade the RAM (memory) with great difficulty. It requires complete disassembly of the iMac and removal of the logic board. This is not a user serviceable upgrade.
If you iMac is currently using a 1TB HDD or Fusion drive I would instead suggest purchasing an external USB-C SSD and reinstalling MacOS onto that. Those drives are fast enough to use drive space as virtual memory. See: Use an external SSD as your startup disk … - Apple Community
Same answer if you meant how to add more storage. Instead of upgrading the iMac use an external high capacity USB-C SSD.