The ability to learn a new language varies greatly by person, but theories suggest that the best time to learn a second language is between ages 2 and 12.
There is an idea known as the Critical Period Hypothesis that states that the best time to learn a language is from age 2 to puberty. This means that by the time most kids reach high school, when they usually begin taking a second language, it is past the critical period. This does not mean that they cannot still learn, but it is easier to learn when the brain is still “plastic” or easily adaptable.
As we grow older, our brains begin to compartmentalize. This means that we begin to assign tasks to either the left or right side. Of course, our brains don’t literally handle only one task on one side, but this theory goes a long way to suggesting why our brains develop better when we are younger. This is one reason why people who learn a language when they are younger are less likely to speak with an accent.
It should be noted that any individual at any age can learn a new language. The ease of learning the new language decreases as you get older. As a child, you can learn a new language more easily than as an adult.