What is the purpose of a small wing near the cockpit on the front of some planes?
That would be a canard you see on the airplane.



An aircraft designer may adopt the canard configuration to reduce the main wing loading, to better control the main wing airflow, or to increase the aircraft’s maneuverability, especially at high angles of attack or during a stall

Canard foreplanes, whether used in a canard or three-surface configuration, have important consequences on the aircraft’s longitudinal equilibrium, static and dynamic stability characteristics.

Many pioneers initially followed the Wrights' lead. For example, the Santos-Dumont 14-bis aeroplane of 1906 had no "tail", but a box kite-like set of control surfaces in the front, pivoting on a universal joint on the fuselage's extreme nose, making it capable of incorporating both yaw and pitch control.



I hope this has helped.