Cloud computing was developed by blending virtualization and grid computing technologies. Its purpose is to provide Internet-based, on-demand, and consumption-based access to pools of computing resources in a measurable, adaptable, and scalable manner. Task scheduling is essential to cloud computing to ensure the performance of cloud services. However, inefficient scheduling can lead to resource issues such as under-allocation and over-allocation, which wastes resources and degrades service performance. Therefore, metaheuristic algorithms are incorporated into task scheduling systems to efficiently and timely distribute complex and diverse incoming tasks to limited resources. This study aims to analyze task priorities and precisely assign them to virtual machines. This is achieved by utilizing the Black Widow Optimization (BWO) algorithm. The primary objectives are to reduce time and energy consumption, improve task success rates, and optimize turnaround efficiency. Ultimately, these improvements aim to enhance the overall trustworthiness of the system.