Using statistics from 2014 (because that's when I last did the research) San Juan's murder rate was lower than the murder rate of Detroit, New Orleans, St. Louis, Baltimore, Newark, and Oakland. It was a tad worse than Chicago. It's also important to keep in mind that most murders in Puerto Rico are the result of gang on gang warfare and just like everywhere else there are some good neighborhoods and some bad neighborhoods. Compared to Mexico San Juan's murder rate is a fraction of the murder rate of cities like Acapulco and lower than infamous border cities like Tijuana.
Puerto Rico as a whole has a higher murder rate than the USA and Mexico because of its ridiculously high population density. It's a small island (roughly the size of Connecticut) but it has one of the highest population densities in the states. Even in rural areas you're only a stone's throws away from your neighbor. In the USA and Mexico, however, you average the murder rate of thousands of safe and quiet towns with the murder rate of a few bad cities so you end up with relatively good numbers.
To give you some perspective, if you were to choose between Mexico and Puerto Rico without intimate knowledge of the two places you would probably choose Mexico because it has a lower murder rate than Puerto Rico. But if you were to choose between Acapulco and San Juan you would definitely choose San Juan because its murder rate is less than a third than the murder rate of Acapulco even though San Juan is Puerto Rico's deadliest city.