Answer: If there's a pattern to be found in which article precedes the names of countries, or even if one is used, I haven't discovered it. It's one of those aspects of the language that you either need to memorize or pick up as you learn the names of the countries and hear them used.
Fortunately, however, there aren't a lot of countries where the article is used, and even then with a few exceptions (particularly la India, El Salvador and la República Dominicana) its use isn't mandatory. So while you can say el Brasil to refer to Brazil, Brasil by itself will also do just fine most of the time. The article seems to be used more often in speech than in contemporary writing (where, for example, Estados Unidos is frequently referred to without the article).
Following are the most common countries and other geographic units that you'll hear or see used with the article. Names where the article is mandatory or close to it are shown in boldface:
la Arabia Saudita (Saudi Arabia)
el Brasil (Brazil)
el Camerún (Cameroon)
el Cuzco (city in Peru)
los Estados Unidos (the United States)
las Filipinas (the Philippines)
la Habana (Havana)
La Haya (The Hague)
el Irak (Iraq)
el Japón (Japan)
el Líbano (Lebanon)
La Meca (Mecca)
los Países Bajos (the Netherlands)
el Reino Unido (the United Kingdom)
la República Dominicana
Remember also that the article commonly is used before the name of any country if you are modifying it with an adjective or a prepositional phrase. For example, soy de España ("I'm from Spain"), but soy de la España hermosa ("I'm from beautiful Spain"). Similarly, México es interesante ("Mexico is interesting"), but el México del siglo XVI era interesante, "16th-century Mexico was interesting."