Dynamic Resource Optimization for Energy-Efficient 6G-IoT Ecosystems