There are quite a lot of differences.
Dirty is probably the most straightforward word. Dirty is the opposite of clean and it is a good general-purpose word to describe something that needs a wash!
The others can all relate to dirty things but they have other meanings too:
Foul - implies something is horribly dirty and unpleasant, and often bad smelling. It also has other meanings, all of them negative. For example, it can mean "tangled", and its most common use is in sport where a breach of the rules is usually known as "a foul", and one player might be said to have fouled another.
Nasty means unpleasant generally, in some cases due to being dirty, but it is more often used to describe someone's personality ("what a nasty man")
Muddy is very specific and always means covered in mud.
Mucky is more regional and light-hearted. If something is mucky it is usually a bit dirty but not disgustingly so. It is often used where children are involved - there's a famous episode of the kids' programme "In the Night Garden" called "Iggle-Piggle's Mucky Patch", for example. I remember being called a "mucky pup" in the north of england if I got dirty while playing outside.
By the way, some of the words have a sexual meaning too: you may come across "dirty" or "nasty" used to describe various people or practices in books, movies or song lyrics, for example, and this is generally an insult.
"Mucky" is used more rarely and the implication is more Benny Hill-style rudeness than anything more serious. Another similar double meaning would be "smutty" which means both dirty and a but rude.