The answer is that guitars are expensive because they are made of exotic materials and require a lot of handcrafting. The wood used in the body and neck of a guitar is usually solid wood. It means that it has a single piece of wood running throughout the entire body.
The top and back of most guitars are made from spruce or cedar, which are both very light and strong. The neck of a guitar is made from maple or mahogany, which is also very light and strong. The top of the neck is usually made from ebony or rosewood, which has a very smooth texture and feels great against your fingers when playing.
Guitars also require a lot of other parts besides just the body and neck. They need to be fitted with frets (which can be done by hand), have strings put on them, have bridges attached to them, have pickups installed in them (this requires soldering), etc. It takes quite a bit of skill to do these things well.
Besides these reasons for why guitars are expensive, some other factors may help explain why they cost so much money:
They are handmade by skilled craftsmen (and women).
Each guitar is unique because each one has its own fantastic set of woods which makes it sound slightly different.
They are made with high-quality materials that are expensive to purchase in bulk (e.g., maple, ebony, rosewood, mahogany).