Both “going against the grain” and being “on the level” are expressions from carpentry.
When a bladed instrument is used to smooth a wooden surface it only works when applied with, or in the same direction as, the grain, otherwise it’s a mess.
A level ensures the precision of a frame alignment.
Someone that is going against the grain is usually doing things wrong, and so is probably not as trustworthy as someone on the level.