According to ABC News, A convention is "a formal meeting of members, representatives or delegates, as of a political party, fraternal society, profession or industry.” Although conventions have been a tradition that dates back to the 19th century, they are not legally required by federal or state law. In addition, there is nothing in the U.S. Constitution that dictates that a convention is required to nominate a presidential candidate.
Each party establishes its own rules for nominating its candidate. The main purpose of the convention is to nominate a party's candidates for president and vice president. The number of delegates needed to win the nomination is based off of a formula- one half, plus one of the total delegates available need to be won by a single candidate during their primary season. The number of total delegates needed however, is not constant- that can change every cycle.
According to the Discovery Channel, “Political conventions are attended by elected delegates from each state. While there are different ways to choose a delegate, depending on the state as well as the party, the key point is that all delegates are chosen because of their support for a specific candidate and not just because they're members of the party. The two main political parties use two different methods to choose their delegates. Democratic delegates are elected using a proportional system, by which the number of delegates representing a particular candidate is directly related to the percentage of votes the candidate received in the primary or caucus. In contrast, Republicans use a winner-take-all system to choose the party's delegates. In this system, the candidate who receives the majority of votes in the party primaries or caucuses wins all of a state's assigned delegates. The number of delegates each state receives depends on its population as well as the support it has given to a party's candidates.”
For more information about how political conventions work, go to How Stuff Works.