Well, I think it differs for the various Grand Slams, but it basically works like this:
World #1-32 more or less fill the top 32 slots, which are seeded.
The rest is filled with people who qualified through other tournaments and Wild Cards.
Wild Cards are, I believe, up the the tournament. You are probably going to get more Australian players in the Australian Open, just to get them out there.
I think players who were formally great but have dropped can request a WC and are often granted it to improve the quality of the tournament.
Andre Agassi won Wimbledon, I believe, as a Wild Card, which is highly rare.
I am fairly new to tennis so I could be completely wrong, lots of salt should be taken with the following:
I believe that the top 100 ranked players are invited to grand slams and don’t have to do anything past merely having a ranking in that range. I imagine it would go to ranking 101 and lower if someone else confirms that they won’t be able to play.
The other 32 are qualifiers and wildcards. How many of each specifically I don’t know
Mahaloth has the right idea, but there are many more players that qualify based solely on rankings, and none that qualify by winning tournaments other than the one Australian Open qualifying tournament.
The top 104 men and 108 women qualify automatically. There are 8 wild cards and the remainder come from the qualifying tournament. The draw (PDF of the men’s draw here) shows a (W) after the wild card entries and a (Q) after those who came through the qualifying rounds.
If you see an (L), that is a Lucky Loser - someone who just missed out in the qualifying, but was given a place when someone in the main draw dropped out. This is also how John Isner managed to be the 33 seed - Gilles Simon, the 15 seed, withdrew.
The wild cards are generally given to players from the home country, often the up-and-comers. They are also used for established players who do not qualify based on their ranking, for some reason. Hence Justine Henin was given a wild card, as was Karatantcheva. Each of the men’s and women’s draw have a wild card from the USA and France. This is part of a reciprocal agreement - the US Open and Roland Garros will each give a wild card to the Australian Tennis Association (or whatever it is called) to give to one of their players. Ryan Harrison got the US wild card for the men - the USTA ran a qualifying tournament held here in Atlanta to determine how it would use its wild cards.
Anyone not in the top 104/108 and who doesn’t get a wild card can apply for the qualifying tournament. Entry to that is again determined by ranking, with some wild cards. The men’s qualifying has 128 players, of whom 9 are wild cards. All WCs are Australian.
Note that Xavier Malisse was the 1 seed in the men’s qualifiers (and Wickmayer in the women’s). Their ranking had fallen because of their ban for failing to keep drug-testing authorities informed as to their whereabouts.
As for funding, the grand slams are immensely profitable. I do not know for sure, but I think that the prize money is all provided by the organization that runs the event. In the US, that would be the USTA.
I think the numbres Covered_in_Bees! posted are right, but I’m having trouble confirming them. If I remember right, 100 players qualify by having a high enough ranking a couple of weeks before the tournament begins, and then 24 players get into each draw by winning three rounds in the qualifying event. The tennis federation of the home country (the USTA, the All England Lawn Tennis and Croquet Club, etc.) gets to hand out a few (eight?) wildcards to whoever it chooses. Usually they are divided between promising young players from the home country, and older players coming back from injury or who have been successful at the tournament in the past. Goran Ivanesevic was one of those when he won Wimbledon.
Agassi did win the US Open in 1994 as an unseeded player, but he wasn’t a wildcard or a qualifier; he easily made it on ranking points since he was #20 in the world. But there were only 16 seeded players back then. Today there are 32 seeds, so he would have received one. Since the 32-seed system was created I think Ivanisevic (Wimbledon 2001) and Gaston Gaudio (French 2004) are the only unseeded men to win a major, and Serena Williams (Australian 2007) and Kim Clijsters (US 2009) are the only women.
As this affects Wimbledon, it’s the other way round.
In 2007 the All-England Lawn Tennis and Croquet Club, which runs Wimbledon, gave the Lawn Tennis Association (the governing body of tennis in the UK) over £26 million from its profit on the fortnight. By far the main source of income for the tournament will come from TV rights, backed up by licensing contracts and gate money. I’d be surprised if this was different for any of the other three Grand Slams.