Handlebars take care of the steering for bicycles. They are the interface between bike and rider at the front and where the gear and brake levers are normally attached to. Being a contact point between bike and rider means they have a great deal of effect on the comfort of the rider so should be positioned in a way that is both comfortable and also allows safe control of the bike.
There are many different types of handlebars, each suited to different types of bikes and the differing rider's needs. Road bikes predominantly have rounded, drop handlebars but some people find flat bars better for control. Mountain bikes have flat bars or bars with an upsweep to give more comfort and control. Touring bikes can have very different handlebar styles to the norm to give the rider a choice of hand positions on long journeys. Town bikes have many weird and wonderful handlebar shapes each designed to suit the style of bike or needs of the rider.
Whilst handlebars come in many different styles, their are only two sizes of stem clamp diameter (the centre section where the stem clamps on); these are 25.4 and 31.8 (oversize).