Although most writers can’t agree on what the most important element to a story is, setting is almost always at the top of the list. It establishes your story in a real environment — even if that environment happens to be imaginary.
A story’s setting plays several roles.
Placement. It places your story. Giving your characters buildings and landscapes with which they can interact. Imagine The Lord of the Rings without those long expanses of wilderness. Or without the volcano in Mordor? Could it have been as powerful at Mount St. Helens? Would Harry Potter have been as successful without the contrast between the Dursley’s hidden closet under the stairs and the magnificence of Hogwarts? Whether you’re using the world around you or building your own world, setting gives your characters some ground to stand on.
Character. It really is a separate character in your novel — and should be treated as such. Backstory, history, scars from warring parties, indigenous animal and plant life. Your setting is alive and interacting with your characters as much as it is a background. Imagine The Shining without the hotel. Or The Never Ending Story without the Ivory Tower. Could a simple backdrop have driven those characters?
Mood. Climate, weather, decoration, structures — your setting helps set the mood of your story. This mood may enhance your characters’ moods. Or it could highlight your characters’ moods through contrast.
With these things in mind, what are the dos and don’ts of setting?
Don’t describe your entire setting in the first paragraph.
Don’t reference Earth unless your story is set on Earth.
Don’t leave it to the narrator to describe everything.
Do use realistic properties (ie., relativity, gravity, and speed of light) even in imaginary worlds. You can always name them something else.
Do have your characters interact with the setting.
Do include all five senses within your setting.