Emotion plays a crucial role in daily life, influencing cognitive functions such as language comprehension, decision-making, attention, and concentration. With the growing integration of computer systems into our everyday activities, it is essential to understand and detect emotional states accurately. Emotion detection through EEG signals allows direct assessment of the human's internal state and is considered an important factor in the interaction between humans and external devices. In this paper, we introduce a novel feature selection algorithm proposed to improve the accuracy of emotion classification using EEG signals, aligned with decreasing the input dimension to reduce computations, making it more suitable for real-time applications. We performed two experiments utilizing the DEAP and the MAHNOB-HCI datasets. Various features were extracted and employed for emotion classification using SVM, KNN, and XGBoost classifiers. Initially, the highest accuracy for binary emotion classification in the DEAP dataset was achieved with statistical features and the XGBoost model, reaching 78.85% for arousal and 79.02% for valence. In the MAHNOB-HCI dataset, the highest accuracy with statistical features and the XGBoost model was 67.08% for arousal and 62.24% for valence. Subsequently, we applied the grey wolf optimization algorithm as a feature selection method, optimizing the cost function based on XGBoost accuracy. This approach significantly enhanced the classification performance. For the DEAP dataset, accuracy increased to 89.63% for arousal and 89.08% for valence using statistical features. For the MAHNOBHCI dataset, accuracy improved to 84.94% for arousal and 82.29% for valence using statistical features.