This can happen for different reasons. If you have a newer-built house that you bought new or used, sometimes homeowners don't realize they have a Christmas circuit. There would be receptacle outlets (commonly known as plugs) up under the eaves under the rain gutters of the house. Without any lights plugged in, if you turned on the switch, nothing would happen. I try to install those switches inside a front closet so that the other 11 months of the year people don't turn on a switch not realizing it is the Christmas circuit switch. One way to figure this out easily is to look in your electrical panel directory and see if you have a circuit listed as x-mas or Christmas. Lastly, you can plug a receptacle tester in the receptacle you suspect might be controlled by a switch and see if the tester lights up when you turn the switch on.
Another reason you might have switches you can't figure out is that if you have a room without a light in the ceiling, and there is a switch on the wall, you have a switched receptacle. This means that one or more of the receptacles in that room is wired so that half of the receptacle works when you turn on the switch. Usually it is the top half of the switch, but not always. The other half is hot all the time. Code states that you must have a light in the room or have switch receptacles so a lamp may be used and turned on with the switch for room lighting. A common mistake that can happen when receptacles are changed out over time is that people forget to break the tab on the hot side of the receptacle, see photo below. If you forget to do this, both halves of the plug will be hot all the time and essentially the switch won't work.
Another scenario is there are times where lighting gets deleted and the switch remains in the wall. This is not code. If a switch is deleted, a blank plate or insert should be installed to minimize confusion. An insert is a plastic plug that is the same size and color as the switch and is flush to the plate. This is also pleasing to the eye in situations where you have multiple switches and a blank cover plate is not applicable.
Yet another scenario is that it is very possible that the light bulb is burned out. This happens more times than you think. I got a call one day from someone telling me that one of their pendant lights over the kitchen island was not working and they had a large group of people coming the next day and desperately needed it fixed. The first thing I asked was if they had tried to change the light bulb. Of course the answer was yes. The customer explained that they had gone through a drawer and a handful of bulbs. The next thing I asked them to do very calmly was to please take the bulb out that is currently working and try it in the other fixture. There was a long pause on the phone, the next thing I heard was a bunch of incoherent rambling followed by "thank you very much, problem solved." All the bulbs in the drawer were bad and nobody threw them out. This happens so often I decided to write about it. Funny story and I saved the customer money and a trip charge. All in a day's work from the phone!