The above answers are wrong. You should get a can of grease remover spray it on the chain and sprockets leave it to penetrate and then scrub with a brittle plastic brush. This should remove most of the grime and dirt. After cleaning you should spray the chain and sprockets with WD40 to remove moisture and prevent rusting.
In extreme conditions you can remove the chain boil it then wax it but this is unnecessary with an average bike.