Rule #1 - Don't stare at anyone
One of the most important rules on this list, staring is one of the worst things you can do in the gym. Working out is not supposed to be a social event, and most people want to pretend no one else is there when they're working. Keep your eyes to yourself and focus on your workout.
Rule #2 - Keep your phone in your pocket or locker
Nothing is worse than the person who won't put their phone away during a workout. If you want to stare at your phone, either go walk on the treadmill or go home. Keep your phone in your locker so you don't even have to think about it.
Rule #3 - Wipe down machines/benches after you're done
This rule is a common courtesy to the other patrons in the gym. It is no secret that gyms are not the cleanest places in the world, but avoid contributing your own filth to the mix. Make sure to wipe off your sweat when you finish an exercise or use a towel to avoid the problem in the first place.
Rule #4 - Put back all weights when you're done with a lift
Leaving weights out after an exercise is one of the most selfish and irritating things to do in the gym. Be courteous to the next person that is going to use those weights and put them back in their rightful place.
Rule #5 - Respect other's personal space
Believe it or not, you are usually not the only one in the gym at a given time. Give people space to get their workout done without having to worry about you looming right over them.
Rule #6 - Don't block anyone's mirror view
Once again, you are not the only person in the gym. People usually enjoy using the mirror while their working out, whether it is for personal vanity or making sure their form is on point. Either way, find your own parcel of the mirror to avoid blocking anyone else's view.
Rule #7 - Make sure that a machine/bench is open
When advancing to a new bench or machine, look around to make sure no one else is using it. If there is a towel or water bottle on it, chances are someone's already using it. In addition, it doesn't hurt to ask anyone nearby if they are using said machine.
Rule #8 - Don't leave your machine/bench for too long
Piggybacking off of the previous rule, do not leave your bench unattended for more than 2-3 minutes maximum. If you're going to be gone more than 3 minutes, take your stuff with you and let someone else use the machine in your absence.
Rule #9 - Keep the grunting to a minimum
Everyone lets out a bit of a grunt once in a while when working hard, but don't take it overboard and scream at the top of your lungs during every rep. You are just going to make yourself a distraction and look like a major idiot.
Rule #10 - Don't slam weights
Again, once in a while you are working truly hard and have to drop weights to avoid injury. However, most time dropping or slamming weights is unacceptable. Unless you own the gym/weights, take care of the weights and avoid being a distraction.
Rule #11 - DO NOT give advice unless you'asked
This is another vital rule to remember when in the gym. Unless someone is about to severely injure themselves, do not critique anyone unless they ask you for advice. the only other exception to this rule is if you want to offer encouragement or quick tips to a teenager who looks absolutely lost in the gym.
Rule #12 - Don't be an ass
A great rule to follow in the gym as well as in life, having common sense and basic common courtesy will most always cover your bases to not draw unneeded attention to yourself. Look at what the experienced people in the gym are doing and copy that etiquette. Conversely, look at what the people who are distracting and all over the place are doing and avoid those things. Gym etiquette can be very simple if you just act normal and have respect for the other gym-goers.