machado plays a more valuable position(s). They both have their enemies in baseball, too, so I don't think it is the jerk factor. Harper has had the two best seasons of the two of them offensively, and contracts are about offense, I guess.
Offensively they're about equal. Machado is far superior defensively, and so, on balance, Machado is the better player. But Machado is a thug, and that makes people uneasy, which lowers his market value. If there were no baseball, Machado would be an MS-13 member, Harper would at least keep clean (probably not amount to anything).