Just because your marriage ended doesn't mean that your relationship with your ex is over. When you have children together, you will have to continue to deal with each other. How you handle this parenting relationship with your ex can have a profound impact on your children.
When you choose to co-parent with your ex, you are committing to having a good working relationship for the duration of the time your children are minors. This isn't always going to be easy, but the benefits to your children will likely make the effort worth it.
One of the primary ways that your children will benefit from this arrangement is that they will be able to have stability in their life. They will know that they can count on both parents to be there for them. Worrying about when they will see one parent isn't going to be a concern since they will have a very close relationship to both.
Seeing you and your ex working together shows the children that cooperation and mutual respect can help to smooth over situations that they might come across in childhood and adulthood. You are setting a powerful example for how working as a team can help to work toward the common goal.
Your children will also have great memories from their childhood. Since you and your ex will both attend the major milestone events of childhood, those shared memories will be important for them.
These co-parenting relationships aren't without conflicts sometimes. You can show your children how to use mature conflict resolution when this occurs. Just remember that they don't have to know everything that happens in these cases. Sometimes, working things out with your ex in private is the best course of action.