This would be the optimal German tank for WWII:
Starting with a Pz. IV, I would adopt a rear mounted transmission and drive shaft. I would also bolt coilover suspensions to the sides instead of running torsion bars underneath the floor of the tank. This will make the tank roughly 20cm wider and 20cm lower and would make the running gear far easier to fix. It would also allow for a 10cm increase in turret ring diameter and allow for a larger electric motor for faster turret traverse. The increased width of the tank would reduce ground pressure as well, allowing for an increase in mobility in the snow and mud found in Russia. To top it off, I would install a diesel engine and gear the transmission towards production of torque. This will allow the tank strong acceleration over difficult terrain at a slight cost in top speed.
In terms of armor protection and layout, I would extend the casemate on the sides so that it fully overhangs the tracks, allowing for greater internal volume. Additionally, I would slope the front glacis plate and turret front for greater ballistic performance and greater internal volume. Side skirts can be installed for greater protection. The armor thickness of both the front glacis and front turret will be around 80mm and the additional slope will make the armor far more difficult to penetrate.
As for armament, I would install the KwK 42 L/70 gun modified to fire the same 75x714mmR ammunition used by the Pak40 anti-tank gun. I don't quite understand why the KwK 42 and Pak 40 used different ammunition. The longer barrel means lower comparative pressures in any event, allowing for the full potential of the 75x714mm round to be utilized. Thanks to the larger turret ring size, the new Pz. IV can easily accommodate the heavier main armament. Ammunition will be placed in a bustle hanging off the rear of the turret so that a minimum of combustible rounds are in the fighting compartment itself. Gun elevation and depression should be improved slightly, making the tank just a bit better in urban warfare. Also, putting the ammunition in a turret bustle means that a later upgrade for an automatic loader would be much easier to implement.
In terms of secondary armament, I would delete the hull machine gun and give both the commander and loader MG-42s mounted on the roof behind steel gunshields. The radio will be miniaturized and placed in the turret basket itself to be operated by the commander and the 5th crewman deleted. Optionally, an NbW 92mm grenade launcher can be installed for close combat. Lastly, there will be a telephone mounted on the rear of the tank so that infantry can speak directly with the crew inside.
The whole tank should weigh approximately 30 tons (give or take) and possess significantly greater strategic and tactical mobility over the previous Panzer IV while costing approximately the same amount in terms of money and resources. A larger version of this vehicle (let's call it a Tiger because there would be no need for the Panther), would be much the same as the new Panzer IV, but would carry a 88/L71 Kwk 43 and have a combat weight of around 50 tons. Frontal armor on the Tiger would be around 130mm sloped at 50-60 degrees, making engagement for Allied tanks extremely hazardous.
All of these changes are changes that the Germans could have easily made, assuming a PoD in the mid-1930s regarding design decisions. None of this technology was unavailable in the 1930s, nor would it have been overly complicated/implausible for German engineers to come up with such technology on their own.