Whether in a lustrous castle by the sea or dotted across a swathe of fields and mountain chains, a story must take place somewhere. That "somewhere" is part of the setting.
Whether at the dawn of civilization or the high-tech future, a story must take place at some time. That time is the other part of the setting.
There are many options for story settings. Your options are somewhat limited, however, by your genre. Epic fantasy tends to have a setting that mirrors Medieval Europe. Science-Fiction almost always takes place in the future. Literary works have more lee-way, but are usually modern or close to it.
The setting of a story is important as it makes it engrossing for the reader. It also defines technology in-world and can fuel conflict. Books with boring settings tend to end up boring, whether the characters and plot are great or not.
Setting is a major element of story-telling. It shares that distinction with characters and plot. Those three elements meld together, creating a story in the end.