This depends on what you mean by “most beneficial.” It also depends on what you want from your education.
If you are looking to study something that will make you a lot of money, either of these will do. However, you are only likely to really get rich if you specialize in the right kind of medicine or law. General practitioner doctors do not make huge sums of money. Neither to lawyers working in small offices. Medical specialists like surgeons, on the other hand, do make a lot of money as do those who make it to the upper levels of corporate law.
If, by “most beneficial,” you mean “most helpful to society,” then most people would probably say that medicine is the better field. It is true that some lawyers do help people have better lives. However, medicine is a much better field if your goal is to help people. By their very nature, doctors are involved in helping people. Everything a doctor does is oriented toward improving people’s health and, thereby, enriching their lives.
Overall, then, I would say that medicine is more “beneficial,” but law can certainly be beneficial as well.