RB are not making crap in the NFL right now. They are all underpaid. That is the only reason why McKinnons contract seems high relative to what other RB are making because RB salaries have stagnated compared to all other positions in the league.
https://fivethirtyeight.com/features/running-backs-are-finally-getting-paid-what-theyre-worth/
According to
sportrac McKinnon is the 3rd highest paid player on the 49ers roster right now. He costs 5% of their total cap space for 2018.
This is mostly because he has a $5.75 roster bonus for the 2018 season.
Here is how his total contract breaks down.
As you can see the 49ers can cut McKinnon in 2019 and only have $1.5 million in dead cap and McKinnon will have a cap hit of $4.5 million if they decide to keep him, $6 million less than what they are paying him for the 2018 season. The contract is front loaded to get him to sign with them. In 2019 McKinnon will cost 2.8 of their total cap space and he will become their 13th highest paid player.
All teams need to spend a percentage of their total salary cap or otherwise be penalized for not doing so. So every team is going to ovespend on some players, especially teams with a ton of cap space, which the 49ers had this offseason.
The free agent market does not usually have that many good players for teams to spend their excess money on, thus the McKinnon contract.