Community detection is a prominent research topic in Complex Network Analysis, and it constitutes an important research field on all those areas where complex networks represent a powerful interpretation tool for describing and understanding systems involved in neuroscience, biology, social science, economy, and many others. A challenging approach to uncover the community structure in complex network, and then revealing the internal organization of nodes, is Modularity optimization. In this research paper, we present an immune optimization algorithm (opt-IA) developed to detect community structures, with the main aim to maximize the modularity produced by the discovered communities. In order to assess the performance of opt-IA, we compared it with an overall of 20 heuristics and metaheuristics, among which one Hyper-Heuristic method, using social and biological complex networks as data set. Unlike these algorithms, opt-IA is entirely based on a fully random search process, which in turn is combined with purely stochastic operators. According to the obtained outcomes, opt-IA shows strictly better performances than almost all heuristics and metaheuristics to which it was compared; whilst it turns out to be comparable with the Hyper-Heuristic method. Overall, it can be claimed that opt-IA, even if driven by a purely random process, proves to be reliable and with efficient performance. Furthermore, to prove the latter claim, a sensitivity analysis of the functionality was conducted, using the classic metrics NMI, ARI and NVI.