Extending the lifetime and stability of wireless sensor networks (WSNs) through efficient energy consumption remains challenging. Though clustering has improved energy efficiency through cluster-head selection, its application is still complicated. In existing cluster-head selection methods, the locations where cluster-heads are desirable are first searched. Next, the nodes closest to these locations are selected as the cluster-heads. This location-based approach causes problems such as increased computation, poor selection accuracy, and the selection of duplicate nodes. To solve these problems, we propose the sampling-based spider monkey optimization (SMO) method. If the sampling population consists of nodes to select cluster-heads, the cluster-heads are selected among the nodes. Thus, the problems caused by different locations of nodes and cluster-heads are resolved. Consequently, we improve lifetime and stability of WSNs through sampling-based spider monkey optimization and energy-efficient cluster head selection (SSMOECHS). This study describes how the sampling method is used in basic SMO and how to select cluster-heads using sampling-based SMO. The experimental results are compared to similar protocols, namely low-energy adaptive clustering hierarchy centralized (LEACH-C), particle swarm optimization clustering protocol (PSO-C), and SMO based threshold-sensitive energy-efficient delay-aware routing protocol (SMOTECP), and the results are shown in both homogeneous and heterogeneous setups. In these setups, SSMOECHS improves network lifetime and stability periods by averages of 13.4%, 7.1%, 34.6%, and 1.8%, respectively.