Paragraphs, for the most part, are like an essay in compact form. Just as a full piece of writing will be driven by one main idea, so should a good paragraph be held by one. This main idea is often stated in the topic sentence.
Think of topic sentences like a mini-thesis statement. The thesis envelops the main idea of the whole essay the same way that a this kind of sentence encapsulates the subject for the paragraph. All the supporting sentences that look to “hammer in” the main topic mirror what supporting paragraphs do for the main thesis.
What qualities should a topic sentence have? First, it must make an assertion about the subject (both facts and opinions will do). If it doesn’t, then it’s not worth its own paragraph. Make sure that each sentence moves the entire essay forward, rather than keep it at a standstill.
Second, a good topic sentence will need to cover a big-enough idea, such that it can be covered for one sensible-length paragraph. If it’s a statement that can stand alone, best integrate it with other ideas (perhaps, to support a different paragraph). If it’s too general, consider breaking it up into various parts to make it easier to read.
Most sentences of this kind naturally come at the beginning. However, there’s no rule compelling you to stick to that format. In fact, many good writers can hold a topic sentence right up to the last line. For those with less skill, however, try sticking to within the first two complete sentences (and use the best grammar software you can find).