Back in the day, as with today, a
ship's company consisted of
enlisted men and
officers. In addition, there were the sons of
rich people who were
training to become officers. They tended to be young, and this was their
first time away from home.
On board a ship, your bunking arrangements depended on your rank. The captain had the cabin under the quarterdeck. Officers were forward of that, and enlisted or pressed men slept at the bow. Midshipmen were neither officers nor enlisted, and so lived in the middle of the ship, hence the name.
Sometimes, they are referred to as snotties.