Looks fixable - take the lower jockey wheel off (3mm allen) and clean it thoroughly by scratchng the dirt off (most satisfying) and then with something liquid (hot water+dishwash or some solvent)
Use a file or sharp knife to cut away the raised burr. Don't worry about any recess/scratch. Force the bent tooth back into line - if it snaps off then that should still work OK (jockey wheel teeth don't do a lot). Then lube both sides of the bushing and under the side plates, and refit.
Or you can buy a replacement jockey wheel - they're not too expensive, or salvage one off a spare/parts derailleur.
How? Looks like something got stuck between chain and lower jockey wheel, and was "eaten" so it forced the chain out. Possibly a stick, maybe a stone.
Another possibility is the derailleur caught the wheel, though this tends to be a lot more destructive. The lower jockey wheel can't reach the cassette to collide there.
Super unlucky. This kind of thing is not impossible, but rare.
The question should also be "Is the derailleur cage damaged/bent" and "has the frame's hanger been bent?" either of which will make indexing harder. But you likely won't be able to tell until the jockey wheel is cleaned up.
Coincidentally I had an almost identical problem yesterday. In my case the top jockey wheel bolt had come unthreaded, dropping the left side plate. This allowed the jockey wheel to fall off and become lost. The bolt was still there - (held purely by gravity!)
The bike still shifted, except it was clattery and kept jamming the chain.
Did you loose your top jockey wheel too? I can't see it in the photo.