One would use grubby to describe informally and/or disapprovingly something is not very pleasant. You can use it about something is not very clean, and also about somebody's behaviour.
grimy is neither informal nor disapproving. It specifically describes something that is covered in grime, which the Cambridge Dictionary defines as a layer of dirt on skin or on a building.
Grubby has more emotional significance: it's something that you wouldn't want to come into contact with, like a small child whose face is covered with food and snot, or a t-shirt that has been worn for a few days without washing.
Grimy simply states that someone or something is covered in dirt, for example a miner who has just finished a shift and is covered in coal dust, or the building that is next to the mine entrance.