Why is Newton's first law necessary?

Newton's second law says $F = ma$. Now if we put $F = 0$ we get $a = 0$ which is Newton's first law. So why do we need Newton's first law?

I don't think this is obvious from Newton's statement of the Second Law. In his Principia Mathematica, Newton says that a force causes an acceleration. Without the first law, this doesn't necessarily imply that zero force means zero acceleration. One could conceive of other things that also cause acceleration.

A modern person might be concerned about non-inertial reference frames. Someone from Newton's time would probably be more concerned about Aristotelian ideas of objects seeking their own level. But in either case, its necessary to emphasize that forces not only cause acceleration, but that they are the only things that do so (or in the modern formulation, that there exists a frame in which they are the only things that do so).

Newton's first law postulates that there is (at least) one inertial reference frame for every object, in which said object will continue in uniform motion unless acted upon by a force.

Newton second law states that, within the inertial reference frame for any object, $F = ma$.

Without the first law to assert that there is indeed a frame in which $F=0$ implies $a=0$, the second law is vacuous.

Newton's first law is necessary, because it does something. Let's look at what the laws do.

Newton's third law constrains what force laws you consider (effectively you only use/consider force laws that conserve momentum).

Newton's second law turns these force laws into predictions about motion, thus allowing the force laws to be tested, not just eliminated for violating conservation of momentum. This works because he postulates that we can test force laws by using calculus and then looking at the prediction from solutions to second order differential equations.

Newton's first law then excludes certain solutions that the second law allowed. I'm not saying that historically Newton knew this, but it is possible (see Nonuniqueness in the solutions of Newton’s equation of motion by Abhishek Dhar Am. J. Phys. 61, 58 (1993); http://dx.doi.org/10.1119/1.17411 ) to have solutions to F=ma that violate Newton's first law. So adding the first law says to throw out those solutions.

Since you said F=0 implied a=0, let me point out that yes that is true, but Newton's first law says more than a=0 it says that it stays at rest if at rest and has the same constant motion if in constant motion. The second law does tell us that F=0 implies a=0, but that does not mean that the velocity is constant, merely that the acceleration is zero, but if you have a nonzero jerk, then the acceleration can change. Jumping from a pointwise zero acceleration to a constant velocity is just like a student analyzing projectile motion, noting that the velocity is zero at the top and then assuming the projectile stays there forever (student thinks once the velocity is zero for an instant, that therefore the position stays constant forever after). The student ignored the possibility of a nonzero acceleration. To jump from a zero acceleration to the velocity staying constant forever after is to simply ignore the possibility of a nonzero jerk. It is exactly as big an error (to just assume that without a law or principle). A body can experience no force at an instant (and hence no acceleration) and have no velocity at that instant and yet start moving again (if it had a continuous and nonzero jerk at that instant it would have to). So Newton's first law has content, it excludes those motions. And in fact it sometimes forces the jerk to be discontinuous.

In summary: the third law constrains the forces to consider, the second makes predictions so you can test the force laws, and the first constrains the (too many?) solutions that the second law allows. They all have a purpose, they all do something.