A harness in rock climbing is like the safety net below a tight rope walker. It isn't needed to do the job. You can climb without one, but it is there for security and safety. On the off chance you slip, it is best to be in one than not. The harness attaches the climber to the rock.
For safety, you don't have to spend a lot of money on a rock climbing harness. They work the same no matter what the cost. However, comfort or strength of material might compel you to buy a slightly more expensive product. Depending on how often a person goes rock climbing can greatly influence how durable the harness needs to be.
There are two entities that certify rock climbing harnesses for use. They are the UIAA and the CE. You should never buy a harness that wasn't tested.
There are various kinds of harnesses depending on the type of climbing you are doing and based on what is best for the individual. For instance, you would want one that is very light for mountaineering since you will be needing all your strength for the long distance. But rock climbing will require more padding for the rough climb. A sport climber would probably go with just a waist harness that gives movability a little extras. And a beginner might be more comfortable in a waist and chest harness or a full body harness so that they feel more secure.
On many harnesses you will find loops of material attached to the waist area. These are put there to store gear. This keeps needed items close at hand and spread the climbing weight more evenly around the climber. In some cases the leg loops of a harness can be removed. This is for climbers that might be doing a mixed trek and need to move more freely at times.