Inactive memory getsgot a horrible rap due to a crappy name. It should behave been called something like "make your Mac really fast the second, third, and fourth time it does the same task" memory except that's an awful name, too.
Apple re-wrote the activity monitor when it introduced several new features and added compressed memory, so some of this no longer applies to macOS that don’t show “Inactive Memory” but this still applies to Mac OS X memory management as documented against this version of Activity Monitor: https://support.apple.com/en-us/HT201538
Here's how I explainexplained things to someone new to the concept of virtual memory on OS X: