What's a safe distance from the wall to the case?

I think as long as you have space around it for air flow in/out of the fans and enough room to comfortably plug-in and run your cables it should be fine.

If you are worried about dust get a case with filters and place your computer up off the floor, Mine actually sits on a shelf I specially made about 5 feet off the floor, somewhat behind the desk (it is a corner desk).

Keep a can of compressed air and just blow out the case once a month, more or less.