Electricity is magic so I won’t explain the energy that brings the light but headlamps are a rather complex arrangement of lens and reflector. Until the advancement of computer modelling enabled engineers to design differing types of reflectors most headlamps before the 1970’s were fairly similar and simple. In essence they have a bulb which shines light onto a parabolic reflector and then through the lens into the area in front of the car. The parabolic reflector takes the light from the bulb and directs it parallel to the bulb’s axis in straight lines which means that the light is therefore organised (like a torch) and more useful than the scattered light of say a candle flame. The filament of the bulb will be positioned at the focus of the parabola making full use of the reflector to give the greatest light quantity. The parabola has makes all the light waves nice and straight and organised and the lens can do its work to direct the light. The reason why these early cars had round headlamps was that it is the resulting shape for a parabolic reflector. The ribs on these headlamps’ lens’ aren’t for your pleasure they are called flutes, and it is their job to direct the light into the required direction. Nominally downward away from an oncoming driver’s eyes and to the off driver’s side direction.
Moving beyond the simple parabolic shape described above are headlamps that have non-uniform reflectors that combine the work of the flutes with that of the reflector within the reflector itself. This allows the designer greater freedom in what shape the headlamp can be and the reflector and a fluted lens can be paired to give a greater balance between the need to see and the desire to be noticed. They are more complicated to design in principle but can relieve the manufacturer the need to make a fluted lens, instead using a simple, strong polycarbonate cover whilst having the cheaper to produce reflector light the way (ahem). Most modern cars utilise this type of headlamp.
More commonly headlamps are now moving toward a projector style arrangement as they offer the ability to make the unit much smaller in diameter. The main difference to the reflective type lamps above is the incorporation of another lens (condenser lens), shutter and the use of an ellipsoidal reflector rather than the parabolic or modified parabolic explained above.
This is a very basic description of headlamp arrangements, there are other complexities obviously and I encourage you to ask any questions you may have or indeed conduct your own research and help others understand more. (All pictures gratefully and perpetually on loan from wikipedia)