Class is size. Ship 'slots' have a size. You should generally aim to match the class of the module to the class of the slot. Especially for things like FSDs, Shield Generators, power plants e.t.c. As item class (size) defines the ball park stats. E.g. A class 1 FSD on a cobra will give you a TINY jump range as the ship is a much to big mass for the small FSD to handle.
Grade is basically quality. the higher the better. A is the best. Grade will do different things depending on the module. E.g. A grade A beam lazer will have a much lower heat creation, higher damage, a lower power draw. A Class A K warrant scanner will have a much higher range, and complete scans very quickly, as well as having a lower power draw e.t.c.