To improve the quality of service (QoS) needed by several applications areas, the Internet of Things (IoT) tasks are offloaded into the fog computing instead of the cloud. However, the availability of ongoing energy heads for fog computing servers is one of the constraints for IoT applications because transmitting the huge quantity of the data generated using IoT devices will produce network bandwidth overhead and slow down the responsive time of the statements analyzed. In this article, an energy-aware model basis on the marine predators algorithm (MPA) is proposed for tackling the task scheduling in fog computing (TSFC) to improve the QoSs required by users. In addition to the standard MPA, we proposed the other two versions. The first version is called modified MPA (MMPA), which will modify MPA to improve their exploitation capability by using the last updated positions instead of the last best one. The second one will improve MMPA by the ranking strategy based reinitialization and mutation toward the best, in addition to reinitializing, the half population randomly after a predefined number of iterations to get rid of local optima and mutated the last half toward the best-so-far solution. Accordingly, MPA is proposed to solve the continuous one, whereas the TSFC is considered a discrete one, so the normalization and scaling phase will be used to convert the standard MPA into a discrete one. The three versions are proposed with some other metaheuristic algorithms and genetic algorithms based on various performance metrics such as energy consumption, makespan, flow time, and carbon dioxide emission rate. The improved MMPA could outperform all the other algorithms and the other two versions.