With deep mine coal, dirt is often mined along with the coal, such as from the mail or tail gate, road way repairs etc. the dirt goes along on the conveyor belt to the washers etc.
With an opencast mine, the layers of dirt are removed down to the coal seam. The last pieces of dirt are often swept away by a chap with a broom! There are some dirt bands that might be in the seam and they are mined together with the coal. Again if the coal is dirty then it will go to a washery.
The quality of the coal depends on the factors involved millions of years ago when the coal was formed. The main factor being water. Coal that was formed in the UK was from trees etc and sea water. The sea water was dirty in effect which is why UK coal seams contain chlorine and sulphur and other salts etc.
Go to somewhere like Australia and their coal was formed with rain water which was purer. That is why the quality of Australian coal is better than UK coal seams.