With crime sky rocketing in many areas, it is more important than ever to buy a home in a safe community preferably with highly rated schools. Crime rates are published for most cities so it is easy to see how a particular area compares to the national average. And, you can always check out a school district on the Great Schools rating or more importantly the schools that would be in the neighborhood where the home is located. Even if you don't have kids, or plan to put you kids in private schools, don't buy a home in an area that is below a 7 out of 10 on the Great Schools rating because it will tie directly to property values in the event you ever want to sell.
More and more people are moving into gated communities to get that little extra means of security. The best ones and the most expensive from an HOA perspective will be those with manned guard houses. Generally, the homes in gated communities with manned guard houses will also be more expensive. Second best choice and less expensive will be those areas that are gated; but usually just involve clicker or tag on your car window to open the gate. The problem with this scenario is that people just wait for an owner to come by and then they just follow you into the community; but it is still better than nothing.
The good news is that whole house security systems are now pretty cheap to buy and install. The monthly charge may be $30 - $40 a month. If you live in a community without gates, having a security system is a good idea. But just know, if you don't remember to disarm it when you leave your home and the security company calls the police believing somebody is breaking into your home, you will eventually be charged for false alarms and that can be as much as $250 each time. Sadly, we have to worry about security particularly in those cities focused on defunding the police. It is what it is.