There are some good books on this subject you might want to look into. About yards specifically there is:
http://www.kalmbachstore.com/12248.html
And for Operation in General:
http://www.kalmbachstore.com/12231.html
There are many others too.
I'm not quite sure how broad your question is, so forgive me if you already know some of the things in the following 'wall of text'.
There are many kinds of railroad 'yards', but the most common one we think of-and the type it looks like you've modeled-is a classification yard. The main purpose of a classification yard is just what it sounds like; classifiying cars for delivery to their destinations, whether local or further down the line. While classification yards can be located many places along a railroad they are most often located at division points.
Railroads are organized into divisions, usually encompassing a geographic area. These divisions are often further divided into subdivisions. For example, the railway I will model, the Chicago, St. Paul, Minneapolis, and Omaha-the Omaha Road, was divided into two divisions for most of its existence; the Western Division (Nebraska, Iowa, and Minnesota) and the Eastern Division (Wisconsin). The Eastern division had several subdivisions, including the Eau Claire subdivision.
To understand the purpose of yards you have to understand the different kinds of trains that would run over a railroad. There are many different kinds of freight trains: Express, manifest, local, etc. Different railroads might use slightly different terminology for the various kinds of trains, but in the end they all boil down to two basic types: through freights and local freights. A through freight travels from one point to another typically with no stops in between. It carries cargo going from point A to pont B (or points further beyond B). A local freight might travel from point A to point B, or it might travel from point A a certain distance, turn around, and come back to point A (this type of train is oftern called a 'turn'). In any event, a local does just what the name implies-it serves the local industries along its route.
Now that we know the (basic) types of freight trains we can understand what yards do. Again I'll use the Omaha Road as an example. The main classification yard of the Eau Claire sub was actually located just east of Eau Claire in Altoona. At Eau Claire the main line branched off to the west toward Minneapolis/St. Paul and to the North toward Duluth/Superior. Through freight trains originating in Chicago would terminate either in Altoona or Minneapolis (this depends on the era; generally speaking the more modern the era one models the longer the distance between terminals). If the freight was terminating in Altoona it would have cars destined for Minneapolis and points west, Duluth/Superior, and cars for local industries. The Altoona switch crew would break up the train and resort the cars into new trains based on their destination, along with other cars that had arrived on other trains. For example, a through freight might have arrived from Duluth around the same time with cars bound for Minneapolis and local industries. The cars bound for the same destination would be grouped together in new trains. These would either be new through freights (to Duluth/Minneapolis/wherever) or local freights to deliver the cars bound for local destinations.
Many other things would happen in a yard depending on prototype and era. On the Omaha road for example even the through freights from Chicago to Minneapolis would have to stop in Altoona in up through the mid 50's. This is because these freights used Chicago and Northwestern (Omaha's parent company) power, which oftern were the CNW's big class H 4-8-4 locomotives, which due to bridge and curve restrictions could not travel west of Altoona on the Omaha. Yards at division points also often acted as crew change points. Train crews are not machines, they need to sleep too. Even though a train might travel from point A to point B it doesn't mean it might not stop at point C in between and change its crew. And even though it was a 'through' freight these trains likely had a cut of cars to drop off at Altoona bound for local destinations or points north, and would likely pick up cars for destinations west. Which brings up the next concept: blocking.
If a yardmaster is doing his job properly and is not rushed by some factors out of his control (late arriving trains, etc) he will 'block' the train he is making up so that cars with similar destinations are grouped together. In the Chicago to Altoona example, the train would probably be blocked into three sectioon: cars bound for Minneapolis/St. Paul and west, cars bound for points north of Altoona, and cars to be delivered locallly upon arrival at Altoona. So when the Altoona yardmaster has to break down the train upon arrival, he simply has to pull cuts of cars instead of reclassifying the entire train. To show this graphically, a train that has not been blocked may look like this, where each city name represents a car and its destination:
Minneapolis-Duluth-Altoona-Duluth-Minneapolis
In the above example the yardmaster has to resrot each car individually, creating a lot more work. If the train had been properly blocked it would look like this:
Minneapolis-Minneapolis-Duluth-Duluth-Altoona
Here the yardmaster can pull both the Minneapolis cars at the same time, and again for the Duluth cars; saving considerable time and switch moves.
On top of all that there were other considerations, as hinted at in posts above. Hazardous materials such as oil, chemical, etc could not be located directly behind the engine for safety reasons. Certain other loads might be intentionally placed behind other loads to avoid damage also; for example, a hopper of coal would not be placed directly in front of a hopper of wood chips, as the coal dust would 'contaminate' the wood chips as the train moved at high speed.
As you can see there is a lot to consider when operating a yard.
Disclaimer: I'm by no means an expert, I have a basic knowledge at best of this sort of thing. If anything I wrote is incorrect my apologies and feel free to correct me. I also apologize for any bad writing; have a bit of insomnia tonight (6:45 am local time and haven't gone to bed yet).