How do I adjust my handlebars to allow me to ride hands free?
Stability of a bicycle is mostly determined by its geometry: primarily the wheel diameter, wheelbase and front fork geometry. If the rider is not touching the handlebar it has very little effect (its mass and rotational inertia do have some effect).

When a bicycle is moving there is a force trying to align the front wheel with the direction of travel. This is because the contact point of the wheel with the road is behind the axis of rotation of the fork. However, this also means that if the bike is leant to one side slightly, the fork turns in the same direction.

So, to answer the question in the title 'What is the key factor for stable handlebar?', the answer is 'the bike underneath it'.

You cannot adjust your handlebar to make the bike more inherently stable - and you would not want to. The bar should be adjusted for proper riding position. The headtube bearings also cannot be adjusted to make rotation of the fork stiffer and hence hold the bars steady - that would potentially make the bicycle impossible to steer at speed. The bicycle is steered by making is lean slightly, which due to  the steering geometry rotates the fork slightly. If the fork is inhibited from rotating the bicycle will not steer properly.

That said, the length of the stem and width of a bar does have an effect on the steering of a bicycle when the riders hand are on the bars. The further the hand positions are away from the axis of rotation of the fork, the more leverage the rider has and therefore more control, at the expense of slower steering.