Modern information technology, such as the internet of things (IoT) provides a real-time experience into how a system is performing and has been used in diversified areas spanning from machines, supply chain, and logistics to smart cities. IoT captures the changes in surrounding environments based on collections of distributed sensors and then sends the data to a fog computing (FC) layer for analysis and subsequent response. The speed of decision in such a process relies on there being minimal delay, which requires efficient distribution of tasks among the fog nodes. Since the utility of FC relies on the efficiency of this task scheduling task, improvements are always being sought in the speed of response. Here, we suggest an improved elitism genetic algorithm (IEGA) for overcoming the task scheduling problem for FC to enhance the quality of services to users of IoT devices. The improvements offered by IEGA stem from two main phases: first, the mutation rate and crossover rate are manipulated to help the algorithms in exploring most of the combinations that may form the near-optimal permutation; and a second phase mutates a number of solutions based on a certain probability to avoid becoming trapped in local minima and to find a better solution. IEGA is compared with five recent robust optimization algorithms in addition to EGA in terms of makespan, flow time, fitness function, carbon dioxide emission rate, and energy consumption. IEGA is shown to be superior to all other algorithms in all respects.