MCC is the Pearson correlation between the predicted and actual binary labels. It is high only when the model does well on both classes, and it is symmetric: swapping which class is called positive doesn't change it, unlike precision, recall and F1. Brian Matthews used it in 1975 to evaluate protein structure predictions.
Example: 1,000 cases, 50 of them positive. Predicting everything negative gives 95% accuracy and an MCC of 0. A real model with TP = 40, FN = 10, FP = 60 and TN = 890 has 93% accuracy, lower than the useless one, but an MCC of (40 × 890 − 60 × 10) / √(100 × 50 × 950 × 900) ≈ 0.54. Its F1 is 0.53 and its balanced accuracy 0.87.
Chicco and Jurman (2020) argued that MCC is more informative than accuracy and F1 for binary classification, since it can't be high unless all four cells are good. Balanced accuracy, the average of sensitivity and specificity, is another prevalence-robust option. MCC is undefined when a whole row or column of the confusion matrix is zero; libraries return 0 in that case.