In his book "A Social History of the Navy 1793-1815", Michael Lewis gives the following breakdown of the background of Navy officers based on their parents' social status.
Social Status of R.N. Officers' Parents, 1793-1815*
A. Titled People Total Percentage
1. Peers 131 7.3%
2. Baronets 85 4.7%
B. Landed Gentry 494 27.4%
C. Professional Men 899 50.0%
D. Business/Commercial Men 71 3.9%
E. Working Class 121 6.7%
*Some details omitted for clarity (Table I, pg.31)
It would therefore appear that the aristocracy and landed gentry were greatly outnumbered by the lower classes in terms of representation as Naval officers at the end of the 18th Century. However, social rank did seem to reflect itself in terms of the final military rank achieved.
Ranks reached by Officers (from above) in percentages*
A. Titled People Flag-Rank Post-Rank Below Post-Rank
1. Peers 45 44 11
2. Baronets 34 42 24
B. Landed Gentry 21 29 50
C. Professional Men 22 34 44
D. Business/Commercial Men 18 28 54
E. Working Class 2.5 13.5 84
*Some details omitted for clarity (Table III, pg.45)
So while it was possible to become an officer from a working class background, your chances of making it to become a Post-Captain were not that good compared to the almost certainty of commanding your own ship if you were the son of a Peer.
As an explanation of how the promotion mechanism favoured the upper classes, we need to look at how men became commissioned officers and how they were then promoted. In order to join the lowest ranks of commissioned officers, a candidate would need to pass the lieutenant's exam.
In order to qualify for the exam, the candidate was required to have six years of service at sea. This meant that a midshipman joining a ship at 13 could take the exam at 19 (assuming continuous sea service). However, it was not unknown for young gentlemen to be entered onto a ship's books before they ever went to sea. In this manner they could accrue some of their six years "sea service" while safe at home and still be able to take the exam at the earliest opportunity. In contrast a boy from a lower class background would have to join the ship as a 'boy' and work his way into the warrant officer ranks (which required their own exams) before he could qualify to take the lieutenant's exam. As a result, he was likely to taking the exam later in life than his upper class shipmates.
The reason that this is important is that promotion above Post-rank was based on seniority (i.e. the number of years in the role). The sooner you qualified as a Post-Captain, the sooner you would become an Admiral. Also younger, well connected men were more likely to be selected as active commanders than older, less influential ones. This is becomes very important when the service shrinks (as it did dramatically at the end of the Napoleonic Wars). Officers who were not on active service were only provided with half-pay. For an officer from a poorer background this could mean that they could not afford to remain in the Navy (rates of pay in the merchant service were generally higher anyway).
I should note that the figures in the tables do not cover every officer in the RN during the period but a (hopefully representative) sample where the officer's background could be established.
A Social History of the Navy 1793-1815, Michael Lewis (Chatham Publishing, 1960)