To add to what @sam has already answered...
Essentially, when it comes to bringing children to shul we need strike a careful balance. On the one hand children should be trained to daven properly1 but at the same time, they should only be brought to shul,2 providing they do not disturb others.(As noted above in the Mishna Berurah 98:3)
The של"ה הקדוש writes at length at how children can be incredibly disruptive, whether it be running around, shouting, laughing, singing etc. all of which disturb the sanctity of shul. He writes rather strongly:
"והמביא טף בזה האופן לבית הכנסת אין ראוי לו לקוות על זה שכר כי אם לדאג מן הפורענות"
“And one who brings a child in this manner to shul, it is not fitting for him to aspire to receive reward and should rather worry of the punishment that is befitting him”.
Aside from the parent having to interrupt their own davening to play with the child, it can have untold effects of the child’s future outlook, as their strict treatment in Shul may well be something that they negatively associate with shul into adulthood.3
It is therefore worth noting that as well as ensuring that one's child is able to act with the correct conduct in shul, a lot of it is down to the timing. Rav Wolbe
(זריעה ובנין בחינוך, 'בית כנסת ותפילה', עמוד מו) asserts:
"בתפילה צריכה להיות נשמה של יהודי. אם מכריחים את הילד להתפלל כהרגל חיצוני, ואולי גם מכים לו אם אינו מתפלל, ממאיסים עליו את התפילה. אחר-כך, כאשר הוא כבר בחור מבוגר – אין לו שום קשר נפשי עם התפילה, והאשמה רובצת כל ראשם של ההורים שהכריחו אותו להתפלל בגיל מוקדם מדי."
“Tefilla should be in a Jew’s neshama. If one forces a child to daven in a superficially habitual manner, perhaps striking the child if he doesn't daven, they make him despise tefilla. Ultimately, when he is older he will feel no inner connection with tefilla, and the fault will lie with his parents who forced him to daven before he was ready.”4
1 Refer to Shulchan Aruch, Orach Chaim 106:2 where it writes about children within the context of tefillah - "וקטנים שהגיעו לחינוך חייבים לחנכם" -"And children that arrive at the age of chinuch, one is obligated to educate them (i.e. in tefillah)
2 Refer to .תוספות ד"ה 'כדי ליתן שכר למביאיהן', מסכת חגיגה ג which learns from the מצוה of הקהל (which requires children to be brought as it provides reward to those who bring them), that "ועל זה סמכו להביא קטנים בבית הכנסת" – “And upon this, [people] have relied to bring small children to shul”.
3 The Shelah adds there:
"כי יגדלו הנערים על זה המנהג הרע והתכונה הזרה וכל אשר יגדלו עוד יוסיפו סרה להבזות בעיניהם ענין בית הכנסת וקדושתו ולא יתנו כבוד לתורה"
“When the child will grow up accustomed to his ill treatment (of davening) and all who grow up will continue to despise the concept of shul and its sanctity and will not give honour to the Torah”.
4 On the flipside, if a child is ready but they need a lot of assistance as they familiarise themselves with the סידור and the mechanics of תפילה, it may well be worth the father davening properly at an earlier מנין and then be more readily available to help them at a later מנין. In a similar vein, HaRav Chaim Kanievsky שליט"א records a question in his חנוך לנער, פרק א', 'חינוך ל'תפילה' עמוד יח, where the questioner asks what to do if he wants to daven at an earlier מנין (i.e. to daven ותיקין), but he also wants to train his child by taking him to shul but it is too early for the child. In that instance, Rav Kanievsky advises him to daven at the earlier מנין and then go with his son to the later מנין. A lot of it would seem to be basic, comment sense that a parent should use to see whether their child is of the correct maturity to behave in shul and gain from the experience.