This is an interesting one (I should note though that animation is a medium and should therefore not be thought of as strictly for children, although I acknowledge this does not concern your primary question). Now, there’s the question of how the trend began, and also of why it has continued.
In fact, for much of the history of animation on film (at least up to around the late 70s/early 80s, roughly speaking), voice acting was done almost exclusively by voice actors and not big name ('live-action') celebrities. There are some obvious exceptions that come to mind:
- Musician Louie Prima as King Louie and actor Phil Harris as Baloo in The Jungle Book (1967)
- John Hurt as Hazel in Watership Down (1978)
- Orson Welles as Unircron in The Transformers: The Movie (1986), as well as in various TV appearances.
There are probably others, but at the time these did not constitute a trend. However, the trend truly exploded when Robbin Williams was cast as the Genie in Disney's 1992 Aladdin; and while other known actors had been cast in roles in previous Disney films, such as Paige O'Hara in Beauty and the Beast and Vincent Price in The Great Mouse Detective (among others), none were as popular nor as well known as Williams among (casual) moviegoers.
For a little more context on Williams' time voicing the Genie, there is a video essay by Youtuber Lindsay Ellis (linked below) that is very informative on the subject.
It is also worth noting that Williams had already agreed to voice Batty Koda in Ferngully: The Last Rainforest, which was already in production at the time, though ended up releasing the same year as Aladdin (but was not anywhere near as successful as the Disney film, either critically or financially). From this point onwards, the presence of famous actors lending their voice talent to animated films became increasingly common, from Matthew Broderick in The Lion King to, in particular, the main cast of Shrek, notably Michael Myers, Cameron Diaz and Eddie Murphy (arguably, Shrek was the next step in codifying celebrity voice acting into mainstream animated features).
As to the ‘why’? The biggest factor is marketability: it can be easier to sell a film, especially one with an original premise, if it involves actors audiences know and can therefore offer mass-market appeal. More recently, with the insurgence of mainstream CGI features, the cost of producing these films (which makeup the overall Western animation marketshare) is often at least $125 million and sometimes up to $250 million per-film. And so while it costs more to employ big name actors, they are also investing in more expensive animation technology and so are looking for higher returns with each investment. The idea is that, if nothing else, big name actors are not a box office deterrent, and at most generate increased revenue due to the promotion they give to the studio.
I hope this answers everything. For further reading on this topic, I’d also suggest this Animation World Network article https://www.awn.com/animationworld/celebrity-voice-actors-new-sound-animation, which was written in 1999 and gives some further clarification on this issue at the time (as well as discussion of similar trends in TV).
*Just as an aside, I am not including any discussion of anime, as that is a whole other thing, and has little bearing on this trend with respect to Western animation.