Preheat your oven to 375°F and grease a 9x13 inch baking dish with 1 tablespoon of the softened butter.
Arrange a single, even layer of half the sliced potatoes in the prepared baking dish, then evenly sprinkle the diced ham and chopped onion on top.
In a medium saucepan over medium heat, melt the remaining 3 tablespoons of butter, then whisk in the flour and cook for 1 minute until it forms a smooth, bubbly paste.
Gradually pour in the milk and cream while whisking constantly to prevent lumps, then add the salt, pepper, and nutmeg and cook for 3-5 minutes until the sauce thickens and coats the back of a spoon.
Remove the sauce from the heat and stir in 1 1/2 cups of the cheddar cheese until it is fully melted and the sauce is smooth.
Pour half of the cheese sauce evenly over the potatoes and ham in the baking dish, then arrange the remaining potato slices on top and pour the rest of the sauce over everything, gently shaking the dish to help the sauce settle.
Cover the dish tightly with aluminum foil and bake for 45 minutes, then remove the foil, sprinkle the remaining 1/2 cup of cheese on top, and bake uncovered for another 20-25 minutes until the top is golden brown and the potatoes are tender when pierced with a knife.
Let the gratin rest for 15 minutes before serving to allow the sauce to set for easier slicing.