If we look at the other stuff in the picture it tells us what is happening here. You have some sort of thick-ish goo on your chain. It is visible in the narrow links, and also on the links at lower right. You can see smears across the wide links at bottom right. It looks like someone used grease as a chain lubricant. A grease would build up on the rear pulleys and turn them into crud magnets in exactly this fashion.
My easy-peasy way to clean a chain is to use a sacrificial towel or old sock. Then squirt Rock and Roll chain cleaner over the top of and through the chain, with the rag underneath the squirt (its easy to keep the output minimal so you do not make a mess). Immediately wipe the area you just squirted with the sock/rag. Since RnR is a combination of cleaner, solvent and lubricant and works in one pass. That wipe cleans your chain after the squirt immediately softens the crud.
Since you have that goo on your chain, which is unusual, you may need to do two passes. Once this is done, repeat the simple cleaning every few weeks - or less depending on how much you ride. I wait until the chain starts getting noisey and do not pick a set interval.
Rock and Roll is at pretty much every quality local bike shop. Its also on Amazon.
EDIT: Use a screwdriver, held up against the pulley at a 90-degree angle to the side surface to clean the pulleys. Have the back wheel up off the ground and rotate the chain somehow, either pedaling forward (turn the power off!) or backward depending on how your bike works. Every half dozen cleanings or so this is a good routine to scrape the pulleys clean on general principles.