Why would the front edge of an aileron fold outward?
That is an enclosure for a counterweight, either made from steel or lead to balance the aileron and/or reduce control flutter in various flight regimes. The extension provides an additional lever arm to alter the moment of inertia about the aileron’s axis of rotation.  These are usually added or refined during flight testing to remove undesirable flutter or other qualities inherent in the design.  Counterweights are usually installed at the factory with the airplane but custom made counterweights can be used on a specific aircraft to provide a specific feel to the controls to meet customer requirements.  Many high performance experimental category acro aircraft do this on aircraft custom built for a master aerobatic flyer.

The comment above about this providing an aerodynamic counterbalance is incorrect.  Such devices for this purpose do exist but in the form or one or more ‘shovels’ or ‘spades’ on the underside of the control surface.