In most film and television productions today, the action takes place on a “set.” This can be anything from a subway station, to a courtroom to a medieval courtyard. And in most instances, it is going to be more cost effective and practical to build our own subway station, courtroom or medieval courtyard. 

There are a number of reasons for building sets. If the sets are to be used as a part of an ongoing tv series, then you generally will spend many scenes in different episodes in the same location. It is much easier and quicker to build the interior of 
an apartment on a soundstage than it is to carry all the equipment and actors and crew to an actual apartment. 
The same would be true with a subway station where other logistics such as the general public and timing of trains would make shooting a scene problematic.

Sometimes building a set, is the only way to create a scene. There are very few places in the world where actual medieval courtyards exists and where they do, generally will require extensive travel and money, not to mention restrictions on what can be done in and on the property. 

All of these issues and more are taken into consideration when planning a film or television project. The bottom line for any production is to do it as cost effectively and as quickly as possible. In most cases, this will involve building sets.