Depending on what parts of your iMac is dead, you can reuse more parts than just the SSD and HDD.
Join a local Mac community to see what others need.
You can sell to them for a reasonable price, or even give them. It's better than just dump it and create more garbage to the environment.
In my city, a guy have tried to sell his dead iMac 2008 for 30$.