Today, with the emergence and development of malicious software, as well as the increase in the use of digital services, the possibility of data corruption, information theft or other cyber-crimes by malware attacks has increased. Therefore, malware must be detected before it affects large numbers of computers. Recently, many malware detection solutions have been proposed by researchers. However, many challenges limit these solutions to effectively detect multiple types of malware, especially zero-day attacks due to obfuscation and evasion techniques, as well as the diversity of malicious behavior caused by the rapid rate of malware and new types of malware being produced every day. Currently, the speed, volume and complexity of malware have created new challenges for the exchange of data and information in the form of common formats, and malware in this field is growing exponentially and has caused significant financial losses to various organizations. In this regard, researchers have provided many solutions to identify malware using different machine learning algorithms and deep learning models. In this research, a method based on feature selection using Horse Herd Optimization algorithm (HOA) with LSTM classifier is proposed to detect and deal with malware. In order to evaluate the proposed approach, the Evasive-PDFMal2022 workbench dataset has been used. The evaluation results presented in the form of Precision, Recall, Accuracy and F-Measure criteria show that the proposed method has been able to provide far better results in both scenarios than the compared method. In addition to the proposed method, this research will also discuss issues related to malware identification and unique challenges in this field, open research problems, limitations, and future directions.