This paper presents a data-driven farming approach based on explainable machine learning (Explainable ML) to address the challenges of cow health monitoring and yield optimization in dairy farms. Continuous data collection using a 3-axis accelerometer sensor and robust ML methodologies and algorithms provide actionable insights into cow activity and behavior, empowering farmers to make informed decisions and adopt sustainable farming practices. Bluetooth-enabled IoT devices and 4G networks facilitate data transmission, analysis, and inference generation, and the Explainable AI Framework (SHAP) is used to interpret model performance. Focusing on preprocessing accelerometer time-series data (statistical feature extraction, signal processing techniques, and delay-based feature extraction using a sliding window technique), we evaluate various hyperparameter-optimized ML models, demonstrating that the k-nearest neighbor classifier achieves the best performance (AUC: 0.98 on the training set, standard deviation 0.0026, and 0.99 on the test set). Through a detailed comparison of key features and a stability analysis of the selected features, we develop an explainable and practical ML model to support sustainable livestock management.