Why are the angle-of-attack sensors on most airplanes mounted on the forward fuselage rather than at the wing roots? A source of reliable angle-of-attack information is important for airplanes, as flight at an excessively-high angle of attack can cause the airplane to stall, which is generally considered to be an undesirable occurrence.  To this end, airplanes generally have several redundant angle-of-attack sensors (usually consisting of vanes that stick out into, and align themselves with, the airflow, but sometimes using complicated pressure-sensing mechanisms instead) to provide warning of a dangerously-high angle of attack.

These sensors, however, are generally mounted on the forward fuselage, below the cockpit, which is not, for most airplanes, where high angles of attack actually cause problems.  Where AoA matters is on the wings, which produce the lion’s share of the airplane’s lift and which need to be kept from stalling, and where the direction of the local airflow is not necessarily the same as that experienced by the AoA sensors on the forward fuselage.  Exactly how not-same it is depends (as do quite a lot of an airplane’s aerodynamic properties) on the airplane’s airspeed, which is why readings from nose-mounted attack-angle sensors need to be adjusted to correct for the effects of airspeed, which is why (for instance) high-attack-angle protection on fly-by-wire Airbusses is inoperative in the absence of valid airspeed data.

Mounting the angle-of-attack sensors at the airplane’s wing roots, rather than beneath the cockpit, would allow the AoA to be measured directly right where it counts, eliminating the need to correct their readings for airspeed and allowing accurate attack-angle measurement even without any airspeed information at all, so why do most airplanes still have their attack-angle sensors on the forward fuselage instead of the wing roots?
Would installing the AOA vane (or, in general, sensor) at the wing root be more accurate than installing it near the nose? No, it wouldn't. In fact, it may be slightly worse due to the larger upwash at the wing leading edge and the vane protrusion may even negatively interfere with the wing aerodynamics.

Traditionally, AOA measurements are used for stall warning and, if required, stick pusher. During flight tests, the thresholds for stall warning activation (and stick pusher activation) were calibrated to the local AOA measurements from the vanes to satisfy the certification requirements, while minimizing $V_S$/$V_{SR}$ to maximize performance.

In FBW aircraft, if the control laws have AOA dependency, the control law would typically be designed with aircraft AOA (a.k.a free-stream AOA) as specified in wind tunnel and/or CFD. Therefore, the local AOA measurements would need to be corrected to the aircraft AOA before being consumed by the control laws. Answer to this question outlines the methods for such correction during flight test.

Addendum:

There are a number of other AOA measurement devices besides vane and Smart Probe (used on A220 and E170, E190). The most common ones are leading edge orifices or tabs used on GA aircraft (thanks @JanHudec for pointing out). These operate by sensing the movement of the stagnation point as AOA increases. The downside, of course, is that the stagnation point associated with the required margin to stall is different at varying Mach numbers and across high lift configurations.

This NACA report contains a number of wing-mounted stall warning devices tested in the last century.