Shallow is Master Slender's uncle and a justice of the peace (aka local judge) in the "county of Gloucester" (1.1.4). He's always running around reminding everyone of his social status (just below that of a knight) and even brags that his family has had a coat of arms for "three hundred years" (1.1.10-11). Translation: Shallow is a member of the upper class, not a mere commoner, and he wants everyone to know it.
When the play opens, he's all bent out of shape because Falstaff (a knight) has insulted him by poaching deer from his property, slapping his servants around, and breaking into his property. Yet, it's hard to feel sorry for Shallow because the guy is so arrogant and full of himself. Plus, it's obvious he's got a chip on his shoulder because Falstaff technically outranks him: "If he were twenty Sir John Falstaffs, he shall / not abuse Sir Robert Shallow, Esquire" (1.1.2-3).
Seriously? When "Sir Robert Shallow, Esquire" refers to himself in the third person using his full and official title, we get the impression that he is exactly what his name implies—shallow. In other words, Shakespeare seems to be using this character to make fun of people who think they're better than everyone else because they were born into high-ranking families.
But, wait a minute. Didn't Shakespeare apply for a coat of arms sometime between 1596 and 1597 so he could be a "gentleman" instead of just a regular guy without a fancy title? Yep. He sure did. Our favorite playwright was born into a middle-class family but he obviously thought it was important to advance his family's social status. Does that make him a hypocrite? Or, is he just showing us that he's got a sense of humor? You decide.
P.S. Some scholars (like Nicholas Rowe) think that Shakespeare based Justice Shallow's character on a real guy named Sir Thomas Lucy who supposedly busted Shakespeare for poaching deer off private property (source).