I'm dubious about claims that Magic Realism is really separate from fantasy and not a sub-genre. If I'm right, then Latin American countries developed a very rich foundation of fantasy during the 2oth century (if not before).
Magical Realism is fantasy-adjunct, I'd say. I'd also argue that MR fed back in, and contributed to Urban Fantasy, in that it looked at traditions, and set tales in the socio-political zeitgeist of a specific area. Charles de Lint might be slightly more lightweight, but as one of the early UF writers, his books took a good look at urban decay issues in a cross-border region of Canada and the US.
I'm not qualified to answer, as I've not read nearly enough. Yes, Britain, Ireland, the US, and Canada have all good solid, and rich, SFFH (I'm going to include horror, due to crossover fiction and writers). Magical Realism is big in Latin America, but fantasy and horror are gaining traction, and Brazil has a burgeoning eco-punk scene.
Bulgaria has a small but respectable history of fantasy, and Magical Realism, with small amounts of sci-fi, but their literature has traditionally been more poetry-based. Very little is translated, though, so I'm only going on the books I was able to access whilst living there. The Czech Republic and Poland had science fiction early on, but less seems to get to the English language market now.
@alexvss has already mentioned Russia and China. I know Indian cinema produces sci-fi films, so that suggests literature there, as well. They have a good fantasy base, as they use religious motifs to explore normal people's actions in mystical settings. Within the same (much) broader region, both Malaysia and Indonesia are producing some sff literature of note.
However, a trend I've noticed are the rich literary strains coming from Nigeria, and its diaspora, and also the rising visibility of sff produced in the Middle East, and Muslim-majority countries of North Africa through to Southwest Asia.
@A. S. Behsam knows more about that, though, as she is involved in the Iranian fiction scene, and internationally. Again, a diaspora writing in English has brought this more to my attention.
Which countries have the the richest literature? No idea, and it all depends upon individual criteria and taste anyway, so I don't think that it can truly be answered. Personally, I think we're all richer for having varied and diverse viewpoints feeding in, that we can borrow from, and build upon.