My 2 year old daughter is just like your son. She's had constipation issues since she was a few weeks old. She went 10 days without a poop several times before her first birthday. More recently, the past 6-8 weeks, we've had more severe problems. The biggest problem with her is that she had a super hard, painful poop and now she's scared. So, she holds it in. Could he be holding it in? This only causes constipation to get worse. It causes encopresis where the soft, gushy stuff leaks out around the blockage that the they are holding in. Gross, I know, sorry!
Anyway, my daughter has been on 12 grams of Miralax a day for about 6 weeks. We started with a lower dose, but this is what works for her. It really works - it's like a miracle! Our pediatrician gave us TONS of information and spent lots of time talking to us about how safe Miralax is and that it's non-habit forming. According to him, it's not a laxative in the way we think of laxatives - cramping, etc. It's not a stimulant; it simply draws fluid into the bowels (don't ask me how, I have no idea!). There is a lot of research on it and several people have been on it for years and years with no side effects. Of course, that's not the long-term goal... We want them going on their own eventually. However, I think it's pretty safe.
A couple of additional things on the constipation issue - these are some routines we HAVE to follow with my daughter to keep her going IN ADDITION to the daily Miralax dose. They are all pretty common sense things, but being busy moms we forget this stuff!! I literally wrote it down for awhile when it was really bad to remind myself of things to try - maybe some ideas you haven't tried for your son?
She has fruit with every single meal.
She eats fiber rich veggies at least twice a day.
Diluted pear juice every other day - only about 4 oz.
Lots of iceberg lettuce - no nutritional value, but she loves it and it keeps her going!
Only 10-12 ounces of milk each day, the rest water, lots of water - I'm still nursing, so you may need to up that milk intake.
Yogurt with probiotics every single day.
One banana a week at most.
Cheese 3 times a week at most.
LOTS and LOTS of exercise - this problem doubled in severity during the winter months and her activity decreased.
I don't really know what causes some kids to be this way, but I really do think it's just the way some kids are. My husband and I BOTH had similar issues as our daughter does when we were children. Good luck - it's awful, I know. Hang in there!