The ore is wetted by the oil and gets separated from the gangue in the form of froth. The impurities gets wetted by water and remain behind in the sink.
Since the ore is lighter, it comes on the surface with the froth and impurities are left behind.