I would like to use command blocks to swap the contents of two specific inventory slots dynamically, while retaining the item, data value, and stack size. I know it is possible to set a slot to contain a specific item, but I am unsure as to whether or not it is possible to switch them (without a ridiculous amount of command blocks, accounting for every possible item in the game). Is this possible?
You can use a mod to do it. For example, hotbarswapper. It involves no command blocks just if you want to use it on a real server like Hypixel or Mineplex you will most likely be banned for "unauthorized mods." By holding Ctrl and scrolling, you can swap the bars in your inventory, up or down.
I can't remember whether the 10th hotbar slot came up in 1.9 or 1.10, but if you are running one of those you can press F (or your set button) to toggle the blocks in your hand and the 10th slot.