Completely depends on the kid. I have a friend who has three children, one of them self-weaned at 10 months, one she decided to wean at 2 years when the kid was showing no signs of wanting to stop, and her third is currently still feeding at 10 months.
My own daughter nursed until she was 3. It was definitely a comfort thing but I was okay with that - breastmilk continues to have nutritional and health benefits superior to cow's milk for as long as you choose to give it.
The natural weaning age, if you don't push a child to wean in any way, is usually between 2.5 and 7 years. Some will obviously wean earlier and certainly most people aren't going to be comfortable breastfeeding a 7 year old, so it's probably a bit earlier than that in reality, especially since there's a weird stigma about extended breastfeeding.
So I think the "ideal" age is whatever works for the child and the mother. I know my daughter would have nursed beyond 3 if I let her but I was so done with it, and she was only nursing once or twice a day so I knew it wouldn't be a huge shock for her to stop. It was an easy transition so I'd say it was ideal for us.