The rapid development of Internet of Things (IoTs) will result in massive amounts of data to be processed. The 5G technology and fog computing can reduce the service delay. A challenging problem in fog computing is how to efficiently allocate resources to guarantee the quality of service (QoS). Therefore, studying the cooperation between fog computing resources and cloud computing resources is of great significance. For resource allocation, four optimization objectives are considered: minimizing the time delay and cost and maximizing the load balancing and stability of task execution, and an improved Two_Archive2 algorithm using a novel fitness evaluation method and a shift-based density estimation strategy (SDE) is proposed. For the case of resource allocation in fog-cloud computing, the proposed algorithm shows the better performance than the state-of-the-art algorithms and could serve as an effective resource allocation scheme.