Wireless Sensor Network (WSN) is an encouraging technology in various applications like atmosphere monitoring, vehicular systems, and targeting devices. Localization in WSN is performed to identify the current position or coordinates of sensor nodes. The crucial task of localization is to find coordinates without manual configuration and expensive hardware like GPS. This work proposes a new localization algorithm using Modified Black Widow Optimization (MBWO). The proposed method involves an optimal selection of anchor nodes to reduce localization errors. Black Widow Optimization (BWO) is a naturally inspired optimization algorithm encouraged by the unique coupling behaviour of black widow spiders. The performance of black widow optimization is improved by levy flight distribution to escape from local minima. Experimental results show that the proposed MBWO-optimized localization achieves a higher localized node count with minimized localized error compared to other optimization algorithms.