Three most likely causes ...
1. Derailleur body or cage was slightly bent from a previous encounter with a curb or loading in a car, etc. The foce created just enough mis-alignment that the cage clipped a spoke and was pulled in.
2. Similarly if the low limit screw on the derailleur was not adjusted properly, it can allow the derailleur/gage to be pulled past the biggest sproket and into the spokes.
3. If the "B" limit screw was not adjusted properly, shifting to the largest sprocket could have caused the chain to be jammed between the sprocket and upper jockey wheel. The interaction might have forced the chain to jump the sprocket, which dragged the cage/derailleur into the spokes.
There are a few other possibilities, but generally one of the above is usually the cause. The best solution is to routinely check your drivetrain for proper function and adjust it before riding. If not comfortable with adjusting, let a LBS do it periodically. Pay special attention if you think the the derailleur might have come in contact with anything Another option is to install a plastic spoke protector which helps to prevent the chain/derailleur from contacting the spokes if the low llimit alignment is breached.
Hope you're back on your bike again soon!