Dirt and grime buildup is inevitable if you have a coin long enough. Coin cleaning is a major concern for coin collectors because any amount of damage from the cleaning process could reduce the coin's value. If you absolutely must clean a valuable coin, using a mild method and cleaning solution will help preserve the value. If the coin isn't particularly valuable, the milder methods will still work, and, as a bonus, will limit your physical contact with a dirty coin.
Soak the coin in a container filled with either vinegar or grape oil (olive oil will also work). Use vinegar for silver coins, and grape oil for copper. The coin should be soaked until the dirt and corrosion have been dislodged.
Pat each side of the coin with another clean, dry cloth to help it dry. Avoid scrubbing, as this may damage the coin.
Rinse the coin using distilled water.
Set the coin down on a clean, dry cloth and let it dry. If you're cleaning multiple coins, they should be placed on the cloth without touching one another.
If you think the coin is highly valuable, consult a professional coin dealer. Depending on the coin and type of corrosion, it may lose value if you clean it.