Currently, cloud computing and its application is a popular area of research in which, intrusion detection has become an imperative system for detecting several security breaches. The main motivation of this research is to develop an automated intrusion detection system (IDS) for the detection of intrusions in the cloud and internet of things (IoT) systems. After the acquisition of intrusion data from the NSL-KDD, CICIDS2017, Kyoto 2006+, and UNSW-NB15 databases, the Min-Max normalization approach is employed for data rescaling. Then, the relevant attributes/features are selected by proposing pareto optimality based grasshopper optimization algorithm (POGOA), where the selection of relevant features efficiently reduces the system's complexity and computational time. In the POGOA, the relevant features are selected based on pareto optimal solutions that help in enhancing the premature convergence and distribution rate of the traditional GOA. Further, the selected features are given to the stacked autoencoder model for classifying the normal and attack classes. The proposed POGOA with stacked autoencoder model's experiment is conducted using the Matlab environment. The proposed model shows better performance by means of precision, f1-score, accuracy, and recall when related to the comparative models. The proposed POGOA with stacked autoencoder model has obtained 99.32%, 99.84%, 99.56%, and 97.24% of detection accuracy on the CICIDS2017, NSL-KDD, Kyoto 2006+, and UNSW-NB15 databases.