Boil the potatoes in their skins until soft, then let them cool completely. I recommend cooking the potatoes the day before and letting them cool overnight. When completely cool, peel and slice into thin slices.
Hard-boil the eggs, remove the shell, and finely chop the inside with a knife.
Peel and finely chop the onion. Heat the lard or oil in a pan over medium-high heat. Fry the onions in the hot oil until golden brown, stirring frequently. Then add the diced ham, reduce the heat slightly, and fry for a further five minutes.
Grease a baking dish with a piece of lard or other solid fat and sprinkle with breadcrumbs. This step makes it easier to get the finished potato gratin out of the dish without it sticking to the sides.
Start stacking the potato layers in the prepared baking dish. Layer the sliced potatoes first (salt and pepper), then the fried ham and onion, and finally the chopped egg. Continue with another layer of potatoes (salt and pepper again), then a layer of ham and egg, and finish with sliced potatoes.
Heat the oven to 350°F (177°C). Place the dish of layered potatoes in the oven and bake for 10 minutes. Meanwhile, in a bowl, whisk the half and half with the eggs. After 10 minutes, remove the potato dish and pour the milk and egg mixture evenly over the potatoes.
Spread the grated cheese evenly over the surface.
Return the potato dish to the oven and bake until golden on top. This takes about 30 minutes.